Explicitly declare a new variable or array variable.

       Dim Varname[([subscript])] [,Varname[([subscript])] ...]

   Varname     Name for the new variable
   subscript   Number of elements in an array variable

Dim statements are not required unless the VBScript contains an Option Explicit statement.

Unlike many other languages there is no need to specify a data type (integer, string, object etc) All VBScript variables are variants. Most experienced scripters will choose variable names that indicate the data type to be stored e.g. strEmployee.


Option explicit

Dim myString, price
myString="Hello world"

Create an Array Variable with 3 elements:

Dim strPrintQueues(2)
strPrintQueues(0)="HP Deskjet 1200"
strPrintQueues(1)="Kyocera first floor"
strPrintQueues(2)="Mikes printer"

“Listen to many, speak to a few” ~ William Shakespeare


Array - Add values to an Array variable
Private VarName - Declare a local variable/array variable
Public VarName - Declare a public variable/array variable
Equivalent PowerShell cmdlet: $MyVariable = SomeValue

Copyright © SS64.com 1999-2019
Some rights reserved