*NOTE*: The answer to your above question is to use the DIM statement...which means DIMension; you use it to formally declare VBScript variables *before* using them; and, this is meant to set aside sufficient memory space to use the variable in.
EXAMPLE 1/VBScript code...
DIM intX
DIM intY
DIM intTotal
intX=1
intY=2
intTotal=intX+intY
MsgBox(intTotal)
=====
The way to make absolutely certain that each variable has already been declared *before* using it...is to use the Option Explicit statement which is usually written at the start of the program...
EXAMPLE 2a/VBScript code...
Option Explicit
DIM intX
DIM intY
DIM intTotal
intX=1
intY=2
intTotal=intX+intY
MsgBox(intTotal)
intZ=2
MsgBox(2)
...in this case, the program stops when it reaches the variable called: intZ; complaining that this variable is 'undeclared'.
If you were to add DIM intZ...*before* using the variable name...then, the program should work ok; as in the following example.
EXAMPLE 2b/VBScript code
Option Explicit
DIM intX
DIM intY
DIM intZ
DIM intTotal
intX=1
intY=2
intTotal=intX+intY
MsgBox(intTotal)
intZ=2
MsgBox(2)
=====
Finally, this last example shows that you can use the DIM statement to declare not only a 'single' variable, alone, on each line; but, you can also use it in a more compact form by declaring 'multiple' variables all being written on the one same line; with each of these variables being seperated by a comma.
EXAMPLE 3/VBScript code...
Option Explicit
DIM intX,intY,intZ,intTotal
intX=1
intY=2
intTotal=intX+intY
MsgBox(intTotal)
intZ=2
MsgBox(2)
Copyright © 2026 eLLeNow.com All Rights Reserved.