How to fill many texbox by using loop function in VBA

后端 未结 3 1538
忘掉有多难
忘掉有多难 2021-01-24 22:36

I made a user interface in VBA with many textbox. I read an excel sheet and I put all the value of this one in all the textbox of my user inteface. So the user can modify the va

3条回答
  •  星月不相逢
    2021-01-24 23:07

    Iterate the form's control collection.

    An example, say your user form is called myForm, then

    myForm.Controls(i)
    

    gets you a handle for any control in myForm. Now you can use control properties to identify which one you're looking at (label, textbox, button, etc). I'd suggest you use a Tag such as, hmmmm.... "TEXTBOX", to ease the process of id.

    if myForm.Controls(i).Tag="TEXTBOX" then 'it's my textbox ! hurraay!!!
    

提交回复
热议问题