Microsoft Office Tutorials and References
In Depth Information
Creating Wizards
Case Else
BackButton.Enabled = True
NextButton.Enabled = True
End Select
‘ Update the caption
Me.Caption = APPNAME & “ Step “ _
& MultiPage1.Value + 1 & “ of “ _
& MultiPage1.Pages.Count
‘ The Name field is required
If tbName.Text = “” Then
FinishButton.Enabled = False
Else
FinishButton.Enabled = True
End If
End Sub
The procedure changes the UserForm’s caption to display the current step and the total number
of steps. APPNAME is a public constant, defined in Module1 . The procedure then examines the
name field on the first page (a TextBox named tbName ). This field is required, so the user can’t
click the Finish button if it’s empty. If the TextBox is empty, the FinishButton is disabled;
otherwise, it’s enabled.
Programming dependencies in a wizard
In most wizards, a user’s response on a particular step can affect what’s displayed in a
subsequent step. In this example, the user indicates which products he uses in Step 3 and then rates
those products in Step 4. The OptionButtons for a product’s rating are visible only if the user has
indicated a particular product.
Programmatically, you accomplish this task by monitoring the MultiPage’s Change event.
Whenever the value of the MultiPage is changed (by clicking the Back or Next button), the
MultiPage1_Change procedure is executed. If the MultiPage control is on the last tab (Step
4), the procedure examines the values of the CheckBox controls in Step 3 and makes the
appropriate adjustments in Step 4.
In this example, the code uses two arrays of controls — one for the product CheckBox controls
(Step 3) and one for the Frame controls (Step 4). The code uses a For-Next loop to hide the
Frames for the products that aren’t used and then adjusts their vertical positioning. If none of the
check boxes in Step 3 is checked, everything in Step 4 is hidden except a TextBox that displays
Click Finish to exit (if a name is entered in Step 1) or A name is required in
Step 1 (if a name isn’t entered in Step 1). The MultiPage1_Change procedure follows:
Private Sub MultiPage1_Change()
Dim TopPos As Long
Dim FSpace As Long
Dim AtLeastOne As Boolean
 
Search JabSto ::




Custom Search