I have a form in which, every time a button is clicked, an array is filled in with the information of a textbox.
How can I keep the elements in the array and not have it empty every time I use the form? This is the code I wrote:
Dim myArray() As String
Sub button_Click()
If Len(Join(myArray)) = 0 Then
k = 0
Else
k = UBound(myArray)
End If
ReDim Preserve myArray(k To k + 1)
myArray(k) = "Number " & k
End Sub

Public myArray() As String, if you need to use it from different places (modules)... Or declare it asStaticinside the sub, if you need it only for that specific Sub. And, of course, delete/comment the declaration from the form. But, before that, can you explain in words what you try accomplishing? At the first glance it looks that an error will be raised when run the code second time... Do you want incrementing the numeric part after each click? - FaneDuru