Wednesday, December 3, 2008

Fixed VS Dynamic Arrays

'Using Fixed arrays

Dim x(2)

x(0)="how"
x(1)="are"
x(2)="you"

for i=lbound(x) to ubound (x)
msgbox x(i)
Next

'Here we cann't store more than 3 elements. Because this is a fixed length array..

'Using Dynamic Arrays

Dim x()

Redim preserve x(2)

x(0)="how"
x(1)="are"
x(2)="you"

Redim preserve x(3)
x(3)=123

'Here 'x' is a dynamic array and by redeclaring x it can able to store more values into it.

No comments:

Post a Comment