Page 466 - Microsoft Office Excel 2003 Programming Inside Out
P. 466
Part 5: Manipulating Excel Objects
Microsoft Office Excel 2003 Programming Inside Out
To prevent the user from changing the information in the Review text box, the
Review_KeyPress event is used to suppress any character typed. Setting the KeyAscii argument
to zero means that the character the user pressed will not be added to the text box.
Private Sub Review_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
KeyAscii = 0
End Sub
Summarizing the Options
The GenerateOptions routine (shown in the following listing) combines the information
collected in the previous steps of the wizard and displays it for the user’s review. This routine
Chapter 20
is located in the user form module. Remember that this routine accesses the controls that
were placed on the other pages of the MultiPage control as if they were directly on the user
form itself.
Private Sub GenerateOptions()
Review.Text = "Header: " & Header.Text & vbCrLf
If OptionButton1.Value Then
Review.Text = Review.Text & "Option 1 was selected"
ElseIf OptionButton2.Value Then
Review.Text = Review.Text & "Option 2 was selected"
ElseIf OptionButton3.Value Then
Review.Text = Review.Text & "Option 3 was selected"
ElseIf OptionButton4.Value Then
Review.Text = Review.Text & "Option 4 was selected"
Else
Review.Text = Review.Text & "No options were selected"
End If
Review.Text = Review.Text & vbCrLf
Review.Text = Review.Text & "Footer: " & Footer.Text
End Sub
This routine uses a multi-line text box control on which the various choices made by the user
are displayed. In this example, the information from the various controls is copied to the
multi-line text box. Notice that a vbCrLf is appended to the Text property after each line of
information is generated. This forces the next line to be displayed starting at the left edge of
the control.
440

