Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Translating code to .net 1

Status
Not open for further replies.

irishjoe

Programmer
Aug 5, 2002
76
AU
Could someone help me translate a line into vb.net?

I am updating a load of labels from a recordset but need help putting it in a loop rather than doing each one individually.

Code:
For x = 0 To 11
  Me.lblPlayer1.Text = rstMain("FirstName").Value & " " & rstMain("SecondName").Value
Next x

I need to change the reference to lblPlayer1 to something like me(“lblPlayer” & x).text but I cannot get the coding quite right…

 
Code:
For x = 0 To 11
  Me.Controls("lblPlayer1" & x.ToString()).Text = rstMain("FirstName").Value & " " & rstMain("SecondName").Value
Next x
 
Legend! Now I can get back to coding properly rather than loads of statements that are basically the same :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top