VBA Lesson 27: Text Boxes in VBA for Excel
This is an excerpt from Pierre Leclerc (www.excel-vba.com)
In the toolbox the text box icon is: .
The text box is the simplest control that requires an entry by the user. The user types something in it and this value can then be used in your VBA procedure. You will usually add a label to accompany the text box.
For most controls including the VBA for Excel text box there are general properties that allow you to set the font, the color of the font, the color of the background, the type of background, the type of border and other design features.
As its name says it the text box carries text. To use the contents of a text box as a number, to add dollar signs, decimal and other numerical features see the tutorial on Excel macros (VBA).
Adding a Text Box to a Userform
To add a text box to a userform you left click on its icon in the toolbox. You move the cursor to the userform, you click again and the text box appears. You can then resize it to your liking. If you double click on the text box icon in the toolbox you can then click on the form as many times as you need text boxes. When you are finished adding text boxes just click once on the text box icon of the toolbox.
Go to the next lesson