Built-in Constants

Built-in constants are sometimes referred to as intrinsic constants.

VBA.ConstantsChrComments
vbCrChr(13)Carriage return character
vbLfChr(10)Linefeed character
vbCrLfChr(13) + Chr(10)Carriage return - linefeed combination
vbNewLineChr(13) + Chr(10)New line character
vbNullCharChr(0)Character having a value of 0.
vbNullStringString having value 0Not the same as a zero-length string (""); used for calling external procedures.
Cannot be passed to any DLL's
vbTabChr(9)Tab character
vbBackChr(8)Backspace character
vbFormFeedChr(12)Word VBA Manual - manual page break ?
vbVerticalTabChr(11)Word VBA Manual - manual line break (Shift + Enter)


vbNullChar

This constant can be used to test for a null character.
This can also be used for assigning a null character to a string variable.
The vbNullChar constant can be useful when passing string variables to external libraries that require a null-terminated string.
This constant should be used instead of Chr(0).


vbNullString

This constant can be used for assigning a zero-length string.
This can also be used to test for empty strings.
For all practical purposes using a zero-length string ("") is equivalent to using vbNullString.
A zero length string means a string with no characters
vbNullString is a constant used for a null-pointer and is more efficient than a zero-length string
The following four lines are all equivalent.

Dim myString As String 
myString = ""
myString = vbNullString
myString = Constants.vbNullString
myString = VBA.Constants.vbNullString



© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Top

PrevNext