How can I declare and then assign variables dynamically in an iterative loop. For example:
for i = i to some_number
dim "prefix" & i
"prefix" & i = 2 * i
next
Dim MyArray(5)
For x = 0 to 4
MyArray(x) = 2 * (x + 1)
Next
For each thing in MyArray
Wscript.echo thing
Next
For x = 0 to 4
wscript.echo MyArray(x)
Next
If you don't know how many a dictionary is usually easier. It you have two or more items it is easier. From Help. https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/dictionary-object
Dim d 'Create a variable
Set d = CreateObject(Scripting.Dictionary)
d.Add "a", "Athens" 'Add some keys and items
d.Add "b", "Belgrade"
d.Add "c", "Cairo"
Also to make them from text.
MyArray1 = Split("This is a bunch of words", " ")
For each thing in MyArray1
Wscript.echo thing
Next
Execute and ExecuteGlobal. To be honest, there isn't a lot of information to go off in the question.