在vb .net中不使用枚举名称来调用enum [英] call enum without using enum name in vb .net

查看:102
本文介绍了在vb .net中不使用枚举名称来调用enum的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能很容易,但我找不到如何修复它。



我有一个调用vb6 exe的vb .net dll。在vb6中,可以直接调用枚举成员而不使用枚举名称。

但是在vb .net中,我需要使用枚举名称来调用它的成员。



VB6 exe直接调用枚举的memebrs,而不使用枚举名称,当涉及到vb .net dll时,它会失败。

仅供参考,我无法更改vb6的代码。



VB6:

公共类



公共枚举测试

undefined = 0

critical = 1

end enum



结束班



来自vb6 exe的电话:



i = class(critical)



此行直接调用critical并给出1作为i的值,当我使用vb 6 dll作为对vb6 exe的引用



但是当谈到vb .net dll时,上述条件无法说明关键变量未定义

解决方案

当然它没有定义。



它是在VB6类中定义的,而不是VB.NET代码。



你要么完全符合要求......例如classname.Critical(顺便说一下这个语法可能是错误的 - 我不是在浪费时间检查它),在你的VB.NET DLL中定义类似的东西或只传递1的值

This may be easy but i could not find how to fix it.

I have a vb .net dll which calls vb6 exe. In vb6, enum members can be called directly without using enumeration name.
But in vb .net, i need to use enum name to call members of it.

VB6 exe calls memebrs of enum directly without using enum name which fails when it comes to vb .net dll.
FYI, i cannot change code of vb6.

VB6:
public class

public enum test
undefined = 0
critical = 1
end enum

end class

Call from vb6 exe:

i = class(critical)

this line directly calls critical and give 1 as value for i, when i used vb 6 dll as reference to vb6 exe

but when it comes to vb .net dll, the above condition fails saying "critical" variable not defined

解决方案

Of course it is not defined.

It's defined within the VB6 class not your VB.NET code.

You either have to fully qualify it ... e.g. classname.Critical (that syntax is probably wrong by the way - I'm not wasting time checking it), define something similar in your VB.NET DLL or just pass the value of 1


这篇关于在vb .net中不使用枚举名称来调用enum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆