Creating Constants and Variables
Create constants in VBScript with the Const statement. For example: Const MY_STRING = "This is my string." Const MY_PERCENTAGE = 75 Const DATE_OF_BIRTH = #6-1-97# Note that strings are enclosed in quotes (") Dates and times are enclosing in number signs (#) Variables Create (variant) variables in VBScript with the Dim statement, the Public statement, and the Private statement. For example: Dim StrMyTextString Dim IntMyInteger Dim MyArray(10)
If you want to declare variables explicitly, the Option Explicit statement must be the first statement in your script.
Assigning Values to Variables
Values are assigned to variables with = as follows:
IntMyInteger = 200
StrMyTextString = "This is an example string"
MyArray(0) = 23 MyArray(1) = 45 MyArray(2) = 500 ... MyArray(10) = 21
“Whether you think you can or think you can't — you are right” ~ Henry Ford
© Copyright SS64.com 1999-2013
Some rights reserved