Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB6 IDE is changing the case of my enumeration names

Tags:

enums

ide

vb6

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?

like image 632
Starwatcher Avatar asked Jun 24 '09 16:06

Starwatcher


2 Answers

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:

Public Enum tiErrorEnum
  tiNone = 0
  tiWarning
  tiError
  tiDupDoc
End Enum
#If False Then
  Public tiNone
  Public tiWarning
  Public tiError
  Public tiDupDoc
#End If

Simple. The IDE will recognize and hold the enumeration names correctly, and the compiler will ignore the block.

like image 96
Cyberherbalist Avatar answered Sep 27 '22 19:09

Cyberherbalist


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.

like image 29
Kev Avatar answered Sep 27 '22 18:09

Kev