Solved

VB automatically overrides my capitalization

Posted on 2011-02-26
5
357 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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 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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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