Use VBA Constants and Enums

Published on February 7, 2011

VBA contains many internal constants and enumerated types to provide consistency and more readable code. Some programmers like to bypass these internal types and use the numeric equivalents. The most common of these practices is to use 0 and 1 for the Boolean FALSE and TRUE.

You might also be tempted to do (or run into code that does) something like this:


If MsgBox("Do you want to continue", 4) = 6 Then
...
Else
...
End If

Instead of this:


If MsgBox("Do you want to continue", vbYesNo) = vbYes Then
...
Else
...
End If

Just don’t do it.


Tags:
Like this article? Share it!

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Privacy Policy