tags:

views:

1206

answers:

6

Hi all, 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?

+1  A: 

It must be defined/declared in lower-case. Locate the declaration and fix it there. The IDE will always change the case to match the declaration.

DJ
-1 Untrue. VB6 changes name casing as it pleases, regardless of scope and explicit definitions. Just as others have said. No point going to the definition and fixing it here. It will just break some other definition in different scope. It's pretty random, depending on which files were touched last.
Tomek Szpakowicz
-1. Not always true. If you have a team working with version control on the same project, VB6 does sometimes change name casing when you check in. It changes the declaration *and* the usages for its own reasons. Never figured out what triggers it to do it.
MarkJ
A: 

DJ is spot on... VB always changes the case of variables to match the original declaration. It's a 'feature'.

Neil Albrock
If you have the same variable name declared in multiple scopes, but with different casing, it will change *all* of them back and force depending on which file you edited last.
Scott Whitlock
+14  A: 

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...

mercator
Why the downvote? This text is an accurate description.
Konrad Rudolph
+2  A: 

To get past the painful file diff experience, set the VSS option in the diff dialog to do case-insensitive comparisons. That way you'll only see the "real" changes.

Matt Dillard
+2  A: 

Enums are even worse. Getting the case wrong anywhere the enum is used changes the case of the definition.

John Y
It's not just that, it's any variable with the same name as an enum member. Ugh, just sucks.
Scott Whitlock
+1  A: 

Continuing from Mercator's excellent answer...

I'd recommend:

  1. Check out all files (I assume you're using VSS for a VB6 app)
  2. Do a rebuild of the entire project group
  3. Recheck back into VSS

Now base you're the real differences rather than the 'auto' changes that VB6 has tried to apply.

Andrew Bickerton
So your solution is: Let it change everything as it wants (meaning: randomly) and live with it? Great! Sorry. I'm just working with code merged from several projects with differing naming conventions. My (otherwise small) checkins are mostly a noise of random changes in name casing. I've had enough!
Tomek Szpakowicz
yes that is my recommendation, VB is trying to change the case of your variables for a reason (not 'randomly'), if you want to see only what you have changed AND you want to use Visual Studio to do it, create a baseline first.
Andrew Bickerton
Or use a different editor, but if you open it in Visual Studio later on you're in the same position.
Andrew Bickerton
By 'randomly' I mean whichever version it sees first it imposes on all other occurences, regardless of type, scope, etc. So either your resulting casing is random or you'll have to inspect all names and fix them by hand to have this 'baseline'. As if VB6 forms weren't a pain to merge without this.
Tomek Szpakowicz
Problem with this method is that it only resaves the files with the changed case if you actually edit the file. So between steps 1 and 2, you'd have to make some minor edit to every file (in the IDE) and save them all.
Scott Whitlock