Microsoft Office Tutorials and References
In Depth Information
Columns(3) is another way of expressing Columns(“C:C”) . The “3” refers to
C being the third letter in the alphabet, which corresponds to the third column
from the left in the worksheet grid. If it were column D, the syntax notation
would be Columns(4) and so on. There is no schematic advantage to using one
style of expression over the other, but I included the numeric expression here
so you can be aware of it, and use it in your macros if it feels more intuitive for
you to do so.
It’s a good practice when constructing UserForms to give the users an indication that confirms what
they’ve just done. In this example, a Label control can be near the CommandButton that confirms
the visible or hidden status of column C, with the following code:
Private Sub CommandButton1_Click()
Columns(3).Hidden = Not Columns(3).Hidden
Label1.Caption = “Column C is “ & _
IIf(Columns(3).Hidden = True, “hidden”, “visible”)
End Sub
A TextBox is most commonly used to display information that is
entered by a user, or is associated with a cell through the TextBox’s
ControlSource property, or is entered programmatically, such as
to display a calculation result or a piece of data from a worksheet
table. You have probably seen TextBoxes when you’ve entered
information on electronic forms, such as when you’ve entered your name,
address, and credit card number when making a purchase online.
Figure 19-3 shows a UserForm with three TextBox controls. In
this example, I’ve entered my first and last name, and a password
that is represented in the figure as a series of asterisks. UserForms
are a good way to greet your user and ask for a password with a
TextBox, and with the TextBox’s PasswordChar property, you can
set any character (in this case an asterisk) to appear instead of the
password, so no one else sees the password as it is being typed.
figurE 19-3
Formatting of TextBoxes is limited to the entire TextBox entry. For example, if
you want any portion of the TextBox’s contents to be bold, the entire contents
must be bold.
Search JabSto ::

Custom Search