I would like it so that every time a cmd button is pushed, whatever is in the textbox is automatically added to the array, in to the next available spot. Does anyone know how this would be done?
Thanks
Printable View
I would like it so that every time a cmd button is pushed, whatever is in the textbox is automatically added to the array, in to the next available spot. Does anyone know how this would be done?
Thanks
This should work....
Code:Option Explicit
Dim sArray() As String ' declare dynamic array
Private Sub Command1_Click()
On Error Resume Next ' call to UBound raises error number 9 if it has not been dimensioned yet
Dim iCt As Integer
If Not Trim(Text1.Text) = "" Then ' assure user input something
iCt = UBound(sArray) + 1 ' get new number of array elements
ReDim Preserve sArray(iCt) ' Change the dimensions of the array
sArray(iCt) = Text1.Text ' add current text to the array
End If
End Sub
Can you tell me why, when I do this, It complains to me, array already dimensioned?
Thanks