Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB6 Editor changing case of variable names

Tags:

ide

vb6

I'm not much of a Visual Basic person, but I am tasked with maintaining an old VB6 app. Whenever I check out a file, the editor will replace a bunch of the uppercase variable names with lowercase automatically. How can I make this stop!? I don't want to have to change them all back, and it's a pain to have these changes show up in SourceSafe "Differences" when I'm trying to locate the REAL differences.

It is changing it automatically in the definition, too: Dim C as Control becomes Dim c as Control. Dim X& becomes Dim x&. But it doesn't do it all the time; for example, three lines down from Dim x&, there's a Dim Y&, uppercase, which it did not change. Why's it do this to me?

like image 625
Laure Avatar asked Oct 29 '08 23:10

Laure


2 Answers

Since I always find this thread first looking for a solution to messed-up casing, here is one Simon D proposed in a related question:

If you just need to fix one variable's casing (e.g. you accidentally made a cOrrectCAse variable and now they are all over the place), you can correct this for good by adding

#If False Then     Dim CorrectCase #End If 

to the beginning of your module. If you save the project and remove the statement later, the casing remains correct.

Using Excel VBA I often accidentally change all Range.Row to Range.row by carelessly dimming a row variable inside some function - with the help of Simon D's solution I can fix this now.

like image 123
Marcus Mangelsdorf Avatar answered Sep 28 '22 02:09

Marcus Mangelsdorf


Continuing from DJ's answer...

And it won't only change the case of variables in the same scope either.

It will change the case of all variables with the same name in your entire project. So even if they're declared in uppercase in one place, another module might have different variables using the same variable names in lowercase, causing all variables in your project to change to lowercase, depending on which of the declarations was loaded (?) or edited last.

So the reason your C and X variables are changing case, while the Y isn't, is probably because C and X are declared somewhere else in your project too, but in lowercase, while Y isn't.

There's another mention of it here, where they mostly seem concerned with such variable names conflicting when case is being used to differentiate local from global variables. They end up going for prefixes instead.

The only alternative I can think of is to use some other editor with VB6-highlighting capabilities to do your editing...

like image 27
mercator Avatar answered Sep 28 '22 02:09

mercator