Skip to content

Using a variable to identify a textbox

Kim

Asked Oct 24, 2006, 7:30 AM EDT2 answers
Share
LinkedInX

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

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mahesh Chand
    0
    User Form.Controls property and loop though the controls.
    0
  • 0

    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

    0