Solved

VB automatically overrides my capitalization

Posted on 2011-02-26
5
352 Views
Last Modified: 2012-06-21
I prefix string variables with "s", and integer variables with "i".
I made the mistake of dimensioning:
Dim sTR As String.
Instead of troubling to spell the variable out: sTableRuns

I have an integer:
Dim iTR As Integer.

iTR is computed. I wish to convert it to a string:

sTR = Str$(iTR)
But VB changes this to sTR$(iTR)

Realizing my mistake, I renamed the variables iTableRuns and sTableRuns.
But it is apparently too late.
Now, VB insists on re-formatting the function name Str$ to sTR$, and it doesn't work!

Help! What can I do?

I tried a global find and replace. It said it made the replacement, but it didn't.

There has got to be an option buried somewhere to turn this automatic editing feature off. I don't know where it is.
0
Comment
Question by:NormaPosy
5 Comments
 
LVL 81

Assisted Solution

by:zorvek (Kevin Jones)
zorvek (Kevin Jones) earned 100 total points
ID: 34989706
Use the global find/replace but make sure you have the case sensitivity turned on.

Kevin
0
 
LVL 11

Accepted Solution

by:
kbirecki earned 300 total points
ID: 34989819
Do you still have "Dim sTR as String" somewhere in your code?  VB6 may be triggering off that to do the autocorrect, if I understand your question correctly.  If you do, remove that and it should stop trying to change other code.  Try searching your project for "Dim sTR" and see if it turns anything up.
0
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 100 total points
ID: 34990934
Str() is a VB function. I have noticed that if you get the capitilisation of reserved words wrong in VB6 or VBA, they tend to stay that way indefinitely, so I think that you have run into this minor bug.
0
 

Author Closing Comment

by:NormaPosy
ID: 34993778
zorvek: I did that. Didn't help. Good suggestion, though.

GrahamScan: You are correct. I've seen this happen before. When naming variables, stay away from reserved names. But there are a lot of those.

The moral is: Don't be lazy with abbreviated variable names.

kbirecki: Not trusting a global find-and-replace, I tediously went through the entire code, renaming that variable. Didn't help. Str stayed sTR. But today, when I reclaimed the code from Source Safe, the problem fixed itself!

SourceSafe probably has nothing to do with it. AFTER renaming the variable, storing, exiting, then re-loading seemed to do the trick.

Question: Is that "$" in "Str$()" necessary? I think it is a back-compatible thing for code written in the old Quick Basic", and the function itself works with or without the "$". Correct?

Thank you all for your help. I thought I was in deep trouble.

- - Norma
0
 
LVL 11

Expert Comment

by:kbirecki
ID: 34996669
Yes, $ is optional.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now