How to initialize an array?
With the keyword ‘Dim’ we can initialize an array.
E.g.,
Dim Arr(2)
Arr(0) = “a”
Arr(1) = “1”
Arr(2) = “c”
Note: Without size declare the array like this , Dim Arr()
If we want to initialize again the array at run time, then we can use the keyword ‘ReDim Preserve’
E.g.,
Redim Preserve Arr(3)
Arr(3)= “hi”
E.g.,
Dim Arr(2)
Arr(0) = “a”
Arr(1) = “1”
Arr(2) = “c”
Note: Without size declare the array like this , Dim Arr()
If we want to initialize again the array at run time, then we can use the keyword ‘ReDim Preserve’
E.g.,
Redim Preserve Arr(3)
Arr(3)= “hi”
Comments
Post a Comment