INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • 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.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

VBA Visual Basic for Applications (Microsoft) FAQ

Office / VBA General

Variable Naming Conventions... Avoid the Pit Falls. by SQLBI
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

My Archive

Resources

Close Box

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:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close