How to declare and initialise dynamic arrays in VB script?

I have a for loop in which I am reading from an excel file. I want to put some values in an array. I tried doing:

i = 0
Dim arrayClientOrderID()
arrayClientOrderID(i)= ClientOrderID
i = i + 1

The above gives me an error. I don't know the size of the array because I am looping through each line of the excel file and taking the values for Client orderID. How can I assign and initialize dynamic arrays.
ReedsAsked:
Who is Participating?
 
hlarseConnect With a Mentor Commented:
Dang typos

ReDim Preserve arrayClientOrderID(i)
arrayClientOrderID(i)= ClientOrderID
0
 
hlarseCommented:
Try this inside your loop:

ReDim Preaserve arrayClientOrderID(i)
arrayClientOrderID(i)= ClientOrderID
0
 
ReedsAuthor Commented:
works, thanks
0
 
RobSampsonCommented:
Reeds, please accept an answer to close this question.

Thanks,

Rob.
0
All Courses

From novice to tech pro — start learning today.