Very Busy (VB) Mail Order
Do the housekeeping required to setup your project.
This includes:
- Creating a New Project Directory
- Saving the Form
- Saving the Project File
In addition to the main module, there are three additional forms and a module so add these components and save the project so that all of the peices are properly named and are stored in the project directory.
Specifications
The main and summary forms have been used in previous labs. These will be detailed later in the lab. What has been added for this week, is the About and Splash forms, and the Module which now holds the Public global variables and Sub Main() which drives the program by first showing the Splash Screen and then route the logic into the Main form.
About
Design a form with a static logo and labels describing the application and you, the author. Also include a Command Button that the user will click to return back to the main form. Changethe Form Caption to indicate that this is an About dialog.
Private Sub cmdOK_Click()
Unload Me
End Sub
Using Unload here is probaby a better choice than Hide as the About Box is rarely used and should be removed from memory and it's resources released.
Splash
The Splash Screen is almost identical to the About box. It also contains a Command Button, but clicking the button to close must unload the Splash Screen and the Show the main form.
Private Sub cmdClose_Click()
Unload Me
frmMain.Show
End Sub
Like the About Box, unloading the Splash Screen from memory is a better choice than hiding it. Changing the Border Style property of the form to Fixed Dialog takes away the Title Bar and the Max, Min, and Close controls. A Caption change is not necessary as the Title is not displayed.
Sub Main()
The Project Properties selection must be changed to start the program with Sub Main()
instead of frmMain. This subroutine allows the management of the splash screen. Show the
Splash Screen, and Load the Main Form. I think of this load as a Pre-Load function as
anything that is to take place in frmMain's Form Load event can begin. See above that the
main form is displayed only when the user closes the Splash Screen.
frmSplash.Show
Load frmMain
In addition, the Shared Public Variables are declared in the Code Module
The Application
So far, nothing has been done to address the actual application that is being developed. This chapter concentrated less on the problem solving and more on the additional forms and the shared variables. Here are some of the application highlights:
This lab has removed the summary information from the main form and now uses a separate form. There are no Module Level variables as before as the shared variables are now part of the Code Module.
All of the work to show the summary totals is performed in Summary's Form Activate
Private Sub Form_Activate()
Dim sngTax As Single
Dim sngFinalTotal As Single
Dim intWeight As Integer
If UCase(g_strState) = "CA" Then
sngTax = g_sngAmountDueTotal * g_sngTaxRate
Else
sngTax = 0
End If
' Note the Function Call to Calculate Shipping base on
Total Weight
g_sngShipAndHandleTotal = _
g_sngShipAndHandleTotal
+ sngCalcShipHandle(g_intWeightTotal)
sngFinalTotal = _
g_sngAmountDueTotal
+ sngTax + g_sngShipAndHandleTotal
lblAmountDue.Caption = FormatCurrency(g_sngAmountDueTotal)
lblShipping.Caption = FormatCurrency(g_sngShipAndHandleTotal)
lblSalesTax.Caption = FormatCurrency(sngTax)
lblFinalTotal.Caption = FormatCurrency(sngFinalTotal)
End Sub
Requesting a summary now is performed by selecting a menu option as opposed clicking a button to update the form as in the lab from Week 4. The logic is no different. Only the "hook" has changed. Clicking the menu option causes the summary form to be Activated. It is this Activation that performs the summary logic. In Week 4, this logic was directly invoked, and this week, it is indirecty triggered by the Form Activate.
The logic in the Main form has not changed except that much of the code has been moved out into other project components.
The dialogs for Color and Fonts are unchanged.
Here is a copy of the completed lab from last week
This completes the lab