F.Mysir
F.Mysir

Reputation: 4206

VBScript and concatenation of variable

I do not want to use arrays but want to concanate variable in order to devide some variables with one loop for example something like this:

Dim varr1,varr2,varr3,varr4,i
i=1
varr1=2
varr2=5
varr3=8
varr4=9
Do While i < 5
  varr&i = (varr&i)/2
  i = i + 1
Loop

Could this be done in any way?

Upvotes: 0

Views: 5214

Answers (2)

Gurmanjot Singh
Gurmanjot Singh

Reputation: 10360

We can use the Execute command to get what you need.

Dim varr1,varr2,varr3,varr4,i
i=1
varr1=2
varr2=5
varr3=8
varr4=9
Do While i < 5
  Execute "varr"&i&" = (varr"&i&")/2"
  'Execute "MsgBox varr"&i                                'un-comment this line to see the desired output
  i = i + 1
Loop

Upvotes: 0

0liveradam8
0liveradam8

Reputation: 778

Dim concat
concat = varr1&varr2&varr3&varr4

You cannot automatically iterate through each of these variables unless you store them in an array.

Upvotes: 0

Related Questions