I declared:
Public HList(0) As MyType
and then used:
Redim Preserve HList(Ubound(HList) + 1) As MyType
and I get the error "already dimensioned". Someone help?
Printable View
I declared:
Public HList(0) As MyType
and then used:
Redim Preserve HList(Ubound(HList) + 1) As MyType
and I get the error "already dimensioned". Someone help?
That is because you have declared the array as a fixed size array. You need a dynamic one.
Code:Public HList() As MyType
I did this, no error occurs, but Ubound(HList) returns error "subscript out of range", and no data has been stored as it should have.
its because it has no data
Code:Dim Counting As Long
Dim HList() As String
Private Sub Form_Load()
Counting = 0
End Sub
Private Sub Command1_Click()
ReDim Preserve HList(Counting)
HList(Counting) = "Hello" & Counting
MsgBox HList(Counting)
Counting = Counting + 1
End Sub