Dynamically declare an array in VBScript

How to define an array dynamically in VbScript ?

Dim i,j
i= Inputbox("Enter array's dimension First one")

j= Inputbox("Enter array's dimension Second one")

These lines just convert the datatype by converting the data values from string type to integer type, simply because the Inputbox always returns data as string.

'The below definition does not work.
'Just because Vbscript does not have the feature to dynamically declare an array size
Dim array(i,j)

However the same can be attained by below line of code

Redim array(i,j)
What it does is redefine the array size at run time.
Just comment the earlier declaration.

Post a Comment

Previous Post Next Post