VB6 IDE 正在更改我的枚举名称的大小写
我需要维护一些 VB6 应用程序,并且在涉及枚举名称时遇到了一个奇怪的问题。 VB6 中 Intellisense 的工作方式应该是,如果我的变量名被定义为 Dim Abraxis as String,并且我在编码时键入 abraxis,IDE 会在我留下单词时立即将其更改为 Abraxis。 但是,我发现如果我有这样的枚举设置,例如:
Public Enum tiErrorEnum
tiNone = 0
tiWarning
tiError
tiDupDoc
End Enum
并且我在语句中使用其中一个枚举,例如
ErrorNum = tinone
期望 IDE 修复大小写,它不会将tinone更改为tiNone ,但它确实将枚举成员的 def 更改为tinone! 简直就是倒退啊!
有解决方法吗?
I'm required to maintain a few VB6 apps, and I have run into a weird problem when it comes to enumeration names. The way Intellisense in VB6 is supposed to work is that if my variable name is defined as, say, Dim Abraxis as String, and I type abraxis while coding, the IDE changes it to Abraxis on the fly as I leave the word. However, I have found that if I have an enumeration set up like this, for example:
Public Enum tiErrorEnum
tiNone = 0
tiWarning
tiError
tiDupDoc
End Enum
and I use one of the enums in a statement, such as
ErrorNum = tinone
expecting the casing to be fixed by the IDE, it doesn't change tinone to tiNone, but it does change the def of the enum member to tinone! Exactly backwards!
Is there a workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
就在这里。 这看起来有点奇怪,你可能想评论一下为什么在代码中这样做,这样未来的开发人员就不会对此感到困惑,但这就是你想要做的。 将枚举添加为编译器指令代码块内的公共项(当然,编译器看不到它)。 您最好在枚举声明的正下方执行此操作,如下所示:
Simple。 IDE 将正确识别并保存枚举名称,编译器将忽略该块。
Yes, there is. It's kind of odd-looking, and you probably want to comment on why you're doing it in your code so future devs don't get perplexed about it, but here's what you want to do. Add the enumerations as Public items inside a compiler directive code block (so the compiler can't see it, of course). You should do this preferably right below the enumeration declaration, like this:
Simple. The IDE will recognize and hold the enumeration names correctly, and the compiler will ignore the block.
这是编辑器中的一个错误。 我似乎记得,如果您键入枚举的名称而不是使用智能感知,它会更改声明中枚举值名称的大小写。
This is a bug in the editor. I seem to remember that if you type the name of an enum rather than use the intellisense it changes the case of the enum value name in the declaration.
诀窍是始终限定您的枚举:
智能感知将在按点后正确列出枚举。 我认为如果你的枚举命名得当,这也将有助于代码的可读性。
The trick is to always qualify your enumerations:
Intellisense will then correctly list the enumeration after pressing dot. I think this will also aid code readability if you enumeration is well named.