Im new to creating array and had a question. Say if you are creating an array and you dont know the total number of items that are going to be in the array. How do you use it without getting a null error. Note that I know I can add the array like so:
Dim myArray("1", "2", "3", "4", "5") as string
Say for instance a user is entering name(s) into a textbox and I want to add them into an array. How would I accomplish this :
This what what I have so far and im getting a null error:
Dim myArray() as string
myArray(0) = "John"
myArray(1) = "Jim"
myArray(2) = "James"
You are getting the exception because you haven’t define the length of the array. You can use ReDim to define the lenght, something like:
But it appears that you don’t know the length of array either at compile time or run time then its better to use List or ArrayList. Something on the following line: