Enum and Type capitalization behavior

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:33
Joined
Feb 28, 2001
Messages
30,342
I had occasion to define a data structure using the Type declaration and also had to define an enumerated list of values that one of the Type's members could assume. So ...

I did the Enum like this:

Code:
Enum Btn_Move
    BP_NoMovement
    BP_Conventional
    BP_Reversed
   ...
End Enum

All was well in the world and I started coding. But then, I was typing and was going to use Intellisense to correct my capitalization. In the body of my code, I typed 'bp_reversed' for something intending for the text to become 'BP_Reversed' - but instead the definition inside the Enum block became all lower-case! The tail wagged the dog!

OK, the fix is trivial - go back to the Enum definition block and retype the names in the intended mixed case. Then the references in the code body get fixed up just fine. So this falls into the category of Annoyance, not fatal error.

The same thing happened when I used the Type declaration with mixed case, but then wanted Intellisense to match case with the declaration. Same problem occurred - had to go back and retype the definition to get the references in the code body to reset to the correct capitalization.

And it should be noted that resetting the definitions DID in fact reset the capitalization elsewhere in the document, so automatic corrections WERE working. I was just surprised that the reference changed the definition as easily as changing the definitions changed the references. I didn't think it was supposed to work that way.

Has anyone else seen this kind of behavior?
 
Yes, I've observed this before. You can do this with a referenced type library too, like DAO. It's all caps by default, but you can overtype it like . . .
Code:
dim rst as dAo.Recordset
. . . and all the code modules in your project will show it as dAo.

But with your Enum, I don't think you have to go back to the module in which your Enum is declared to do corrections. The fact that you can upset this apple cart anywhere in your code means you can also right it again, anywhere in your code, so if you type this . . .
Code:
Dim tmp As Btn_Move
tmp = bp_nomovement
. . . you can just go back and amend this line to . . .
Code:
tmp = BP_NoMovement
. . . and that changes it back in all your modules.

What I had in one project that was more annoying is I had an ID field I'd named "mID," and every instance of the VBA.Mid() function was somehow re-capitalized as "mID()" and that is, to this day, stuck like that in that project.
 
I remember one project where an object name insisted on changing the capitalisation. I searched everywhere (with V-tools) to find what might have caused it but never found it.

I think I had mistyped it once and it stuck.
 
Glad to know it wasn't just me or my perverse little government-issue computer!
 

Users who are viewing this thread

Back
Top Bottom