Solved

VB automatically overrides my capitalization

Posted on 2011-02-26
5
354 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

809 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