Dim numElements As Integer = Integer.Parse(Console.ReadLine()) Dim strings(numElements) As String For i As Integer = 0 To strings.Length - 1 strings(i) = "Hello, World" Next For Each s As String In strings Console.WriteLine(s) Next
You can also use ReDim Preserve strings(numElements) to resize an existing array keeping current elements. (You can omit Preserve if you want to throw away existing elements.)
array variable
GGavars
and use the following to add objects to the arraylist
Dim
strList As New ArrayListstrList.Add(
"Item1")strList.Add("Item2")
justme2005
Console.WriteLine("Enter size of array: ")
Dim numElements As Integer = Integer.Parse(Console.ReadLine())Dim strings(numElements) As String
For i As Integer = 0 To strings.Length - 1
strings(i) = "Hello, World"
Next For Each s As String In strings
Console.WriteLine(s)
Next
You can also use ReDim Preserve strings(numElements) to resize an existing array keeping current elements. (You can omit Preserve if you want to throw away existing elements.)
More information on declaring arrays in VB.NET can be found here:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/vbcn7/html/vacondeclaringarrays.asp