Hi,
I am trying to use index to assign 10, 30, 50, 70, and 90 to some list boxes names "listbox1", "listbox2", "listbox3", "listbox4", "listbox5".
Please look at this simple code:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Class Form1
Dim MyNumbers(4) As Double
Dim listbox(i) As ListBox
Dim i As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i As Integer = 0 To 4
MyNumbers(i) = 10 + 20 * i
ListBox(i).Items.Add(MyNumbers(i))
Next i
End Sub
End Class
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
The error is "Index was outside the bounds of the array." and it does not get ListBox(1) as ListBox1! What should I do?
Thank you,
Onli
I am trying to use index to assign 10, 30, 50, 70, and 90 to some list boxes names "listbox1", "listbox2", "listbox3", "listbox4", "listbox5".
Please look at this simple code:
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Class Form1
Dim MyNumbers(4) As Double
Dim listbox(i) As ListBox
Dim i As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i As Integer = 0 To 4
MyNumbers(i) = 10 + 20 * i
ListBox(i).Items.Add(MyNumbers(i))
Next i
End Sub
End Class
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
The error is "Index was outside the bounds of the array." and it does not get ListBox(1) as ListBox1! What should I do?
Thank you,
Onli