Solved

VB automatically overrides my capitalization

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Update Access FrontEnd by Version # 9 47
Attention Please 10 49
Clear Filter 8 60
Problem to line 23 54
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

861 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