| Now that we have done all the hardwork of creating a VBA
wizard's navigation buttons and Subway map controls in Tutorial 15 and
16; now comes the fun part - we get to make it work as a Setup Wizard.
Again we have done this exercise to get users used to designing VBA wizards.
We encourage users to follow this design style but to add their own specific
code for say a Mailform Wizard in Word or a Charting Wizard in PowerPoint
or whatever. In fact, there |

Figure 1
|
is a small contest as well. Readers are encouraged to create their own VBA wizards using any application program
that supports VBA. Send those entries to us by email below or to me care of The Computer Paper. If we have enough
entries, the top three wizards will be published in this column and receive $100 each plus a small no-prize.
The Setup Wizard - Intro Page
The Setup Wizard as shown in Figure 1 is from a real application. We shall first change the Intro page. To do so,
make the Intro page active by selecting it in the Properties sheet. Next choose the Image control and draw a rectangle
in the upper left-hand corner of the Intro Page. Change the Image's BackColor property to black. Then choose the
Label control and draw it inside the Image control you have just created. Change the Labels properties as follows:
Caption => Setup Wizard, ForeColor => white, Font to Tahoma, 22p and BackStyle => 0-fmBackStyleTransaparent.
Finally, add the explanatory label as seen in Figure 1 just below the Setup Wizard header label. Again change the
BackStyle => 0-fmBackStyleTransaparent but leave the font and ForeColor the same. Your Intro page should now
look like Figure1.
Info Page
The Info page will gather information about the client prior to automatically logging or phoning it in on the
Logon page. Activate the Info page by clicking on the Intro page and then changing the page selection in the Properties
sheet to Info page. Now we are ready to add the five labels and text fields which will gather registration info
for the ChemEngine software. |
|
First, add five textfields and five labels in the layout as shown in Figure 2. Rename the textfields as txName,
txCompany, txDept, txPhone, and txEmail. Add the label with the warning that the Name, Company and telephone or
e-Mail fields must be filled in. Then add the following code to the setSubwayMap() procedure just after
the Case 0 statement:
txName.Text = ""
txCompany.Text = ""
txDept.Text = ""
txPhone.Text = ""
txEmail.Text = ""
This code guarantees that the Info fields
|
Figure 2 - Info Page
|
|
will be blanked out whenever the user restarts the wizard by clicking on Intro. In addition we want to make
sure all data entered into the textfields are raised to uppercase and trimmed of leading and trailing blanks. Do
this by double clicking on each text field and the adding this one line of code into the Private Sub txName_AfterUpdate()
etc procedures:
txName.Text = UCase(Trim(txName.Text))
txCompany.Text = UCase(Trim(txCompany.Text))
txDept.Text = UCase(Trim(txDept.Text))
txPhone.Text = UCase(Trim(txPhone.Text))
txEmail.Text = UCase(Trim(txEmail.Text))
Now all we have to do is validate the fact that the fields have been properly filled in according to the warning
at the bottom of the Info page. The following code does that
Private Sub InfoValCheck()
If txName.Text = "" Then
MsgBox "Name field must be filled"
Tabs.Value = 1
Exit Sub
End If
If txCompany.Text = "" Then
MsgBox "Company field must be filled"
Tabs.Value = 1
Exit Sub
End If
If txEmail.Text = "" And txPhone = "" Then
MsgBox "One of Phone or eMail must be filled"
Tabs.Value = 1
Exit Sub
End If
end sub
To make sure the validity check is done properly, insert in the Tabs_Change() procedure after both the
Case 2 and Case 3 statements the calling code - call InfoValCheck.
|
Logon Page
On the Logon page we allow the user a way to obtain the enabling code and password. By clicking on the Logon for
password button, the user's registration info is automatically passed to the ChemEngine website where a one-time
enabling code and the first half of a password are automatically generated for the user. The one problem - the
user must be connected to the Internet. In the case they are not - the user can call a toll free number to talk
directly with a ChemEngine registrar and get the info to fill in the first two fields of the Go Page. |
Figure 3 - Logon Page
|
The logon procedure with its connection to the Internet is not included. Rather we just pass the dummy values directly
to the Go Page. The Go page as shown in Figure 4 allows the user to enter their own personalized second half to
the password. Only this two part password is used later on program start up. Like the Info page, the Go page has
a validity check which is picked up in the Finish_Click() procedure. Again this check has been simplified
for demo purposes.
However readers are encouraged to do their own wizards to try VBA. |

Figure 4 - Go page
|
|
|