tags:

views:

1890

answers:

3

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?

+1  A: 

Simple answer: no. The array cannot be made const.

Konrad Rudolph
+3  A: 

An array is the result of a function call (Array()) in VBScript. Only literal values can be made Const. So: No, you can't.

Tomalak
A: 

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
Dscoduc