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?
Best Answer
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.