I want to use an array that I declare once at the top of my code several times. Ex.
Const Quarters = ["Q1", "Q2", "Q3", "Q4"]
For each Quarter q q.Do some work
Etc.
Can this be done in VBScript?
I want to use an array that I declare once at the top of my code several times. Ex.
Const Quarters = ["Q1", "Q2", "Q3", "Q4"]
For each Quarter q q.Do some work
Etc.
Can this be done in VBScript?
An array is the result of a function call (Array()
) in VBScript. Only literal values can be made Const
. So: No, you can't.
Why not just declare the array as public and then assign the array during the start of the script?
Public myArray(3)
arrQuarters = Array("Q1", "Q2", "Q3", "Q4")
For Each Quarter in arrQuarters
wscript.echo Quarter
Next