Explicitly declare a new variable or array variable.

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

   Varname     Name for the new variable.

   subscript   For an array variable, the maximum number of array elements.
               This is zero based so 4 will create a variable with 5 elements,
               and 0 will create an array with 1 element.

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.
You can choose a variable name that indicates the data type to be stored e.g. strEmployee, but this is not enforced.


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