In the last post I showed how to add labels to a VBA userform. Click on the link below to read that post.
How to add labels to VBA UserformsIn this post I will show you how to add textbox controls to a VBA userform. Textboxes are also a very important control type used in the user interfaces. It is the control type used to get free text input from the users. Therefore textboxes are also a widely used control type in VBA userforms.
So now let’s look at how to add textboxes to a form. Showing below is the form we created in our last post.
To insert the textboxes, first we need to click on somewhere in the userform. When clicked on the userform, you should see the toolbox appear like this.
If you can’t see the Toolbox, then click on the “View” menu and select “Toolbox”.
Next, click on the TextBox icon in the Toolbox.
We have selected the TextBox control now.
So now we can create textboxes inside the userform. Take your mouse pointer to the Userform where you want to create the Textbox. You will notice that the shape of the mouse pointer has changed to something like this.
Left click on the mouse and drag it to form a small rectangle like below while pressing the left mouse button.
Release the left mouse button. A TextBox will be created like this.
Now we need five more textboxes for other labels.You can use the same steps above to create those other textboxes. Or else you can create five copies of the textbox you created. To create the copies, right click on the textbox and then select “Copy”.
Then right click again and select paste.
Do this pasting step consecutively for five times. Note that all the textboxes will be pasted in the same spot overlapping each other. Therefore you may won’t see five textboxes. So you can click on the textboxes and move each of them to where you want. Also you can use shortcut keys to Copy and Paste TextBoxes too. Use Ctrl + c to copy and Ctrl + v to paste. I moved the textboxes to infront of each label.
And this is how the form would look like in the running mode.