If I have say 10 textboxes named textbox1, textbox2, textbox3, etc I want to be able to loop through like so
for i = 1 to 10
textbox i.txt = "something"
Next
Does anybody know how to do this
Using a variable to identify a textbox
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Mahesh ChandRank #1 · 393.4K pointsPosted Oct 24, 2006, 7:36 AM EDT
Solitaire85 pointsPosted Oct 25, 2006, 4:34 PM EDT
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each ctl As Control In Controls
If TypeOf ctl Is TextBox Then
CType(ctl, TextBox).Text = "Text added"
End If
Next ctl