Appendix D Visual Basic Constants Supported in VBScript
This appendix is primarily aimed at the Visual Basic programmer who wants to make the jump into VBScript. This appendix covers all of the Visual Basic constants that are supported in VBScript. Constants are useful in script because they allow us to use a specific value without explicitlyreak writing it.
Color Constants
These constants are used within script code to specify particular colors.
Constant | Value | Description |
VbBlack |
&h00 |
Black |
VbRed |
&Hff |
Red |
VbGreen |
&hFF00 |
Green |
VbYellow |
&hFFFF |
Yellow |
VbBlue |
&hFF0000 |
Blue |
VbMagenta |
&hFF00FF |
Magenta |
VbCyan |
&hFFFF00 |
Cyan |
VbWhite |
&hFFFFFF |
White |
Comparison Constants
These constants are used to switch between binary or textual comparisons.
Constant | Value | Description |
VbBinaryCompare |
Perform a binary comparison |
|
VbTextCompare |
1 |
Perform a textual comparison |
VbSunday |
1 |
Sunday |
VbMonday |
2 |
Monday |
VbTuesday |
3 |
Tuesday |
VbWednesday |
4 |
Wednesday |
VbThursday |
5 |
Thursday |
VbFriday |
6 |
Friday |
VbSaturday |
7 |
Saturday |
vbUseSystemDayOfWeek |
Use the day of the week specified for your computer as the first day of the week. |
|
vbFirstJan1 |
1 |
Use the week in which January 1 occurs as the first week of the year (this is the default) |
VbFirstFourDays |
2 |
Use the week that has at least 4 days in the new year |
VbFirstFullWeek |
3 |
Use the first full week of the year |
Date Format Constants
These constants determine how a date is displayed.
Constant | Value | Description |
VbGeneralDate |
Displays a date and/or time. The format is determined by your system settings. |
|
VbLongDate |
1 |
Display a date using your system's long date format. |
VbShortDate |
2 |
Display a date using your systems short date format. |
VbLongTime |
3 |
Display a time using your system's long time format. |
VbShortTime |
4 |
Display a time using your system's short time format. |
Miscellaneous Constants
Constant | Value | Description |
VbObjectError |
2147221504 |
Used as the base for user -defined error numbers . |
MsgBox Constants
These constants specify which buttons and icons appear on the message box, and which button is the default. Some of the constants are also used to determine the modality of the MsgBox .
Constant | Value | Description |
VbOKOnly |
Display the OK button only. |
|
VbOKCancel |
1 |
Display the OK and Cancel buttons. |
VbAbortRetryIgnore |
2 |
Display the Abort , Retry , and Ignore buttons. |
VbYesNoCancel |
3 |
Display the Yes , No , and Cancel buttons |
VbYesNo |
4 |
Display the Yes and No buttons. |
VbRetryCancel |
5 |
Display the Retry and Cancel buttons. |
VbCritical |
16 |
Display the Critical Message icon. |
VbQuestion |
32 |
Display the Warning Query icon. |
VbExclamation |
48 |
Display the Warning Message icon. |
VbInformation |
64 |
Display the Information Message icon. |
VbDefaultButton1 |
The first displayed button is the default. |
|
VbDefaultButton2 |
256 |
The second displayed button is the default. |
VbDefaultButton3 |
512 & |
The third displayed button is the default. |
VbDefaultButton4 |
768 |
The fourth displayed button is the default. |
VbApplicationModal |
The user must respond to the message box. |
|
VbSystemModal |
4096 |
The user must respond to the message box. The message box is always on top in all other windows . |
The following determine which MsgBox button the user has selected. These constants must be explicitly declared within your code before they can be used.
Constant | Value | Description |
VbOK |
1 |
The OK button was clicked. |
VbCancel |
2 |
The Cancel button was clicked. |
VbAbort |
3 |
The Abort button was clicked. |
VbRetry |
4 |
The Retry button was clicked. |
VbIgnore |
5 |
The Ignore button was clicked. |
VbYes |
6 |
The Yes button was clicked. |
VbNo |
7 |
The No button was clicked. |
String Constants
These constants allow for the convenient insertion of nonvisible characters into strings.
Constant | Value | Description |
VbCr |
Chr(13) |
Carriage return. |
VbCrLf |
Chr(13) & Chr(10) |
Carriage return and linefeed combination. |
VbFormFeed |
Chr(12) |
Form feed. This is not useful from within Windows applications. |
VbLf |
Chr(10) |
Line feed. |
VbNewLine |
Chr(13) Chr(10) or Chr(10) |
Platform-specific newline character. |
VbNullChar |
Chr(0) |
Character having the value . |
VbNullString |
String having value |
Not the same as a zero-length string (' ---" ). This is used for calling external procedures. |
VbTab |
Chr(9) |
Horizontal tab. |
VbVerticalTab |
Chr(11) |
Vertical tab. This is not useful from within Windows applications. |
Tristate Constants
These constants are used to switch arguments on or off, or to use the default setting.
Constant | Value | Description |
TristateUseDefault |
-2 |
Use default from computer's regional settings |
TristateTrue |
-1 |
True |
TristateFalse |
False |
VarType Constants
The VarType constants are used to determine the subtype of a Variant . These constants must be explicitly declared within your code before they can be used.
Constant | Value | Description |
VbEmpty |
Uninitialized (this is the default) |
|
VbNull |
1 |
Contains no valid data |
VbInteger |
2 |
Integer subtype |
VbLong |
3 |
Long subtype |
VbSingle |
4 |
Single subtype |
VbDouble |
5 |
Double subtype |
VbCurrency |
6 |
Currency subtype |
VbDate |
7 |
Date subtype |
VbString |
8 |
String subtype |
VbObject |
9 |
Object |
VbError |
10 |
Error subtype |
VbBoolean |
11 |
Boolean subtype |
VbVariant |
12 |
Variant (used only for arrays of Variants) |
VbDataObject |
13 |
Data access object |
vbDecimal |
14 |
Decimal subtype |
vbByte |
17 |
Byte subtype |
vbArray |
8192 |
Array |