Hello everybody,
VERY simple question. Lately I do not use arrays, but lists, which are more efficient. So maybe I forgot something basic about arrays.
'-----------------------------------
This simple code creates an error. The definition of the array is wrong.
The error I get is: Use the "new" keyword to create a object instance.
So, what is wrong is the array declaration?
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim Arr() As String
Dim n As Integer
For n = 1 To 5
Add_to_Array(Arr, n.ToString)
Next
End Sub
Public Sub Add_to_Array(ByRef Arr() As String, ByVal s As String)
Array.Resize(Arr, Arr.Length + 1)
Arr(Arr.Length - 1) = s
' This probably work too
' ReDim Preserve Arr(UBound(Arr) + 1)
' Arr(UBound(Arr)) = s
End Sub
'---------------------------------
Thanks ahead to all helpers,
Moshe.