shows how to use the
For Each...Next
statement to retrieve all the values
available for an application.
Notice that
btnTest_Click
uses the
On Error Resume Next
statement.
This program shows one of the few times where that statement is the correct
one to use. Not every application supports every built-in property. If you try
to retrieve the value of a built-in property that the application doesn’t sup-
port, VBA generates an error. Because there’s nothing that you should do
to correct the error, resuming with the next statement is the correct error-
handling strategy.
After the code retrieves all the built-in document properties, it places the
information in the
lblOutput.Caption
property, which displays the infor-
mation onscreen. The code also enables
btnCopy
by setting its
Enabled
property to true.
The
btnCopy_Click
sub-procedure introduces the
DataObject
type. You
might need to interact with the Clipboard when writing an application. This
object is what you use to perform the interaction. The
DataObject
methods
help you retrieve information from the Clipboard, place information on the
Clipboard, and format Clipboard data.
Working with the Clipboard is normally a two-step process. To place data on
the Clipboard, the code must place it in the
DataObject
first by using the
SetText
method. The next step uses the
PutInClipboard
method to
move the data from the
DataObject
to the Clipboard. To get data from
the Clipboard, follow the opposite procedure. Use the
GetFromClipboard
method to place the text on the Clipboard into the
DataObject
and then use
the
GetText
method to move the data from the
DataObject
to a variable.
Every program that you create should include some means of ending. A
dialog-box–based program, like the one in this section, normally includes a
Quit or an Exit button. A configuration dialog box normally relies on the OK
or Cancel button to perform cleanup and then exit. The
btnQuit_Click
sub-procedure for this example performs a simple task — it uses the
End
statement to end the program.
Saying yes or no with check
boxes and toggle buttons
The
CheckBox
and
ToggleButton
controls are Boolean — controls with a
true or false value. The implication of each control is different. A
CheckBox
control normally indicates yes or no. On the other hand, a
ToggleButton
control indicates an on or off condition. You can use the controls as you see
fit, but this is the normal way to work with them.
165
Do'stlaringiz bilan baham: