The Text Boxes in VBA for Excel
|
613-749-4695 (Peter) |
Tips and Ideas on Excel |
Tips and Ideas on Macros |
VBA Chapter 24C of 24: The Text Boxes in VBA for Excel In the toolbox the text box has this icon . The text box is the simplest control to require an entry from 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. Using the 3 windows in the Visual Basic Editor you will see the following properties in the "Property" window when the text box is selected. Properties The other interesting properties of the text boxes are: - WordWrap to be able to write more that one line on a button, To ask users to submit a password to run certain macros develop a userform with a text box and a command button. In the text box you can modify the "PasswordChar" property so that when the user enters the password nobody around can read it. Use an asterisk, an ampersand or any other character in it. Code The most important ting to remember is that a text box is what its name says it carries text. So if you want to send a numerical value from a text box to a cell you must use the "Val" thing: The same applies when you want to use text box vale in mathematical operations: One of the limitations of the text box is the format. If you want to show dates, numbers with decimals or with a coma for the thousands you need to program some procedure within the "Change" event of the text box. |
Next Chapter: Programming Combo Boxes in VBA for Excel |
VBA Table of Contents |
Discover Even More in 50 Excel spreadsheets |
|
613-749-4695 (Peter) |
Tips and Ideas on Excel |
Tips and Ideas on Macros |
The Text Boxes in VBA for Excel