Microsoft Office Tutorials and References
In Depth Information
15-10) to verify that the user really wants to exit. If the user clicks the Yes button, the UserForm is
unloaded with no action taken. This type of verification, of course, is optional.
Private Sub CancelButton_Click()
Dim Msg As String
Dim Ans As Integer
Msg = “Cancel the wizard?”
Ans = MsgBox(Msg, vbQuestion + vbYesNo, APPNAME)
If Ans = vbYes Then Unload Me
Figure 15-10: Clicking the Cancel button displays a confirmation message box.
The event-handler procedures for the Back and Next buttons follow:
Private Sub BackButton_Click()
MultiPage1.Value = MultiPage1.Value - 1
Private Sub NextButton_Click()
MultiPage1.Value = MultiPage1.Value + 1
These two procedures are very simple. They change the Value property of the MultiPage
control and then call another procedure named UpdateControls (which follows).
The UpdateControls procedure is responsible for enabling and disabling the BackButton
and NextButton controls.
Select Case MultiPage1.Value
BackButton.Enabled = False
NextButton.Enabled = True
Case MultiPage1.Pages.Count - 1
BackButton.Enabled = True
NextButton.Enabled = False