The code i was trying to edit worked in visual basic 6 but i was unable to get it to work, i need to make a control array for 80 textboxes and be able to loop through them. this is the code for the function i am trying to get to work.
Dim strlines() As String
Dim strElements() As String
Dim textboxIndex As Integer
textboxIndex = 0
strlines = Split(data, Chr(10))
If InStr(strlines(0), "Page not found") Then
MsgBox("User Not Found!") ‘Edit this line if you want to change the error user not found message
GoTo TheEnd
End If
For i = 0 To UBound(strlines)
strElements = Split(strlines(i), ",")
For x = 0 To UBound(strElements)
If (strElements(x)) = "-1" Then strElements(x) = "NA" ‘Edit this line if you want to change the error not in highscores message
instance(textboxIndex).Text = strElements(x)
textboxIndex = textboxIndex + 1
Next x
Next i
TheEnd:
End Sub
Control arrays work differently in .NET then they did in VB6. Here is a sample piece of code that will create 10 text boxes on a form.
Dim boxes(10) As TextBox
For i As Integer = 0 To 9
‘Create new textbox
boxes(i) = New TextBox()
‘Set it’s properties
boxes(i).Width = 200
boxes(i).Height = 25
boxes(i).Left = 10
boxes(i).Top = i * 30
‘Add control to current form
Me.Controls.Add(boxes(i))
Next
Related posts: