Thursday, March 29, 2012

Enums in Visual Basic 6

It appears that VB6 allows you to declare enumerations in the code anywhere just like a sub or function.  I declared an enum at the bottom of a bas file.  I declared a function somewhere about that in the code and passed it a parameter of the type of the enum.  The code failed that it did not know the type I was using and the intellisense did not see the enum either.

I moved the enum definition to the top of the bas file at the end of the variable declarions.  At that point the intellisense was happy and so was the compiler.

I did not test it far enough to find out if the error I got was just because the compiler got to my using the type first before it got to the possible error of defining the enum in the wrong place.

No comments: