INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS
Come Join Us!
Are you a
Computer / IT professional?
Join Tek-Tips now!
- Talk With Other Members
- Be Notified Of Responses
To Your Posts
- Keyword Search
- One-Click Access To Your
- Automated Signatures
On Your Posts
- Best Of All, It's Free!
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.
Partner With Us!
"Best Of Breed" Forums Add Stickiness To Your Site
(Download This Button Today!)
"...your web site's great! I've been using this system for almost a year now and find it really, really helpful. The people have been helpful in answering just about any question you post in the forums..."
Where in the world do Tek-Tips members come from?
Office / VBA General
Variable Naming Conventions... Avoid the Pit Falls.
Posted: 7 Oct 03
Many posts on Tek-tips are solved by one helpful member pointing out that the reason a chunk of coded doesn't work is that a RESERVED WORD has been used to define a variable name.
This problem can be avoided and thus save loads of debugging time by adopting simple naming conventions for variables defined at runtime.
By using a 3 letter prefix to all variables created, you can be relatively certain that the reason your code won't run, is not because you've used a reserved word.
I use the following conventions;
DataType Prefix Result
Byte byt bytVarName
Integer int intVarName
Long lng lngVarName
Single sng sngVarName
Double dbl dblVarName
String str strVarName
Boolean bol bolVarName
Not only does this prevent the use of a reserved word, but when you are debugging, you can tell at a glance what data type your variable is, without having to trawl through line after line until you find the Dim statement.
Hope this helps.
Back to VBA Visual Basic for Applications (Microsoft) FAQ Index
Back to VBA Visual Basic for Applications (Microsoft) Forum
Join Tek-Tips® Today!
Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.
Here's Why Members Love Tek-Tips Forums:
- Talk To Other Members
- Notification Of Responses To Questions
- Favorite Forums One Click Access
- Keyword Search Of All Posts, And More...
Register now while it's still free!
Already a member? Close this window and log in.
Join Us Close