Auto incremenet variable
Posted on 2006-04-10
I have a problem with some code. I am trying to programtaicaly add an un determined amount of text boxes, to a form.
The i want to be able to get the data back from these text boxes.
For i = 0 To 5
Dim test1 As New System.Windows.Forms.TextBox
test1.Location = New System.Drawing.Point(x, 3)
test1.Size = New System.Drawing.Size(195, 20)
test1.Name = "test" & i
x = x + 200
This code creates the 5 text boxes as required, but declares them all as test1, so i cannot refernece them to find out what user values have been put into them. Also, even if i could reference them how would i then access the data from say a different button, as at compile time the other code would not know the text boxes are there and produce an error?