Hi,
I would be very thankfull if someone could tell me how can I create textbox by using loop. All thanks in advance for your input and help.
Regards
Hi,
I would be very thankfull if someone could tell me how can I create textbox by using loop. All thanks in advance for your input and help.
Regards
Last edited by murid; 05-20-2010 at 03:05 PM.
You don't need a loop to create a text box.
Use the macro recorder and look at the code it gives when you place a TextBox.
Is your code running too slowly?
Does your workbook or database have a bunch of duplicate pieces of data?
Have a look at this article to learn the best ways to set up your projects.
It will save both time and effort in the long run!
Dave
I am assuming you mean the graphical object textbox, rather than the textbox form control.
You have not provided enough information to describe what you need but the code below will create multiple textboxes in a loop on a worksheet. The boxes will be 200 x 50 with vertical space of 10 in between.
Please Login or Register to view this content.
Interesting, I did it before my first post in 07 and it gave me:
Please Login or Register to view this content.
Hi Guys,
Sorry for not providing more information on my request. Actually I'm trying to create comand button in form wil allow me to generate a textbox control (Forms) by using loop.
Thanks
Last edited by murid; 05-14-2010 at 03:28 PM.
This might be possible (I've never done it and I couldn't figure it out in 5 minutes) but I suspect there is a better way to do whatever it is you want to do. Dynamically modifying form elements is not an ideal programming practice, because it's tricky to reference them, and you can easily develop problems if you try to reference things before you create them. And what if you need to delete them later?
What are you trying to do? You might be better off anticipating what text boxes you might need, then controlling whether they are visible or not based on user activity.
Salam,
The solution below
Private Sub CommandButton1_Click()
Dim control1(4) As Control
Dim y As Integer
y = 0
For i = 1 To 4
Set control1(i) = UserForm1.Controls.Add("Forms.TextBox.1", "mytextbox", True)
control1(i).Top = 100 + y
control1(i).Left = 100
control1(i).Width = 50
control1(i).Height = 50
y = y + 50
Next i
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks