Posted by: Jerry Lees
ASCII, Special Characters, string, String manipulation, strings, VBScipt, working with variables
I just realized I’ve been using Visual Basic String constants in my scripts with little to no explanation. We’ll rectify that situation right now!
When dealing with strings in VBScript, you occasionally need to add formatting characters to a string, so that when it is displayed on the screen or in a file it looks correct. If you know your ASCII chart you can certainly preform this with a “& chr(X) &”.However, if you don’t know what ASCII value a tab is (it’s 9) then you can simply use Visual Basic’s string constants in your scripts and have the added benefit if making it easier to read!
The constants and their meanings are listed below:
|VBTab||A Tab character [Chr(9)]|
|VBCr||A carriage return [Chr(13)]|
|VBCrLf||A carriage return and line feed [Chr(13) + Chr(10)]|
|vbBack||A backspace character [Chr(8)]|
|vbLf||A linefeed [Chr(10)]|
|vbNewLine||A platform-specific new line character, either [Chr(13) + Chr(10)] or [Chr(13)]|
|vbNullChar||A null character of value 0 [Chr(0)]|
|vbNullString||A string of value 0 [no Chr code]; note that this is not the same as “”|