VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 6645 ClientLeft = 60 ClientTop = 345 ClientWidth = 6975 LinkTopic = "Form1" ScaleHeight = 6645 ScaleWidth = 6975 StartUpPosition = 3 'Windows Default Begin VB.CommandButton cmdCalculateCommission Caption = "&Calculate Commission" Height = 495 Left = 4320 TabIndex = 9 Top = 2640 Width = 1215 End Begin VB.TextBox txtSales Height = 375 Left = 4320 TabIndex = 0 Top = 1080 Width = 1095 End Begin VB.Frame Frame1 Caption = "Frame1" Height = 3135 Left = 360 TabIndex = 1 Top = 840 Width = 1815 Begin VB.OptionButton optJeff Caption = "&Jeff" Height = 255 Left = 240 TabIndex = 6 Top = 2520 Width = 1335 End Begin VB.OptionButton optBob Caption = "&Bob" Height = 255 Left = 240 TabIndex = 5 Top = 2040 Width = 975 End Begin VB.OptionButton optGreg Caption = "&Greg" Height = 375 Left = 240 TabIndex = 4 Top = 1440 Width = 1455 End Begin VB.OptionButton optLonna Caption = "&Lonna" Height = 255 Left = 240 TabIndex = 3 Top = 960 Width = 1455 End Begin VB.OptionButton optRandy Caption = "&Randy" Height = 255 Left = 240 TabIndex = 2 Top = 480 Value = -1 'True Width = 1455 End End Begin VB.Label Label1 Caption = "Commission is:" Height = 255 Left = 3000 TabIndex = 10 Top = 1920 Width = 1095 End Begin VB.Label Label2 Caption = "Enter Amount of Sales:" Height = 255 Left = 2400 TabIndex = 8 Top = 1200 Width = 1815 End Begin VB.Label lblCommission Caption = "0" Height = 255 Left = 4320 TabIndex = 7 Top = 1920 Width = 615 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False 'Ch 5 Demo Program #2 'Mr. Minich 'This program demonstrates the use of a general function procedure. It's use makes the program easier to ' understand and it reuses code since the possible very complicated mathematical computation that is ' performed within curComputePercent does not have to be repeated in the If/ElseIf statement 5 times. Option Explicit Const sngVeteran As Single = 0.3 ' sales commission rates for 3 levels of employees Const sngMedium As Single = 0.2 Const sngNewHire As Single = 0 Private Sub cmdCalculateCommission_Click() If optRandy Then lblCommission = curComputePercent(Val(txtSales), sngVeteran) ' Val is actually unnecessary ElseIf optLonna Then lblCommission = curComputePercent(Val(txtSales), sngMedium) ElseIf optGreg Then lblCommission = curComputePercent(Val(txtSales), sngMedium) ElseIf optBob Then lblCommission = curComputePercent(Val(txtSales), sngNewHire) ElseIf optJeff Then lblCommission = FormatCurrency(curComputePercent(Val(txtSales), 0.9)) End If ' Jeff hardwired the code to get a 90% commission and to have ' his output nicely formatted as a monetary amount txtSales = "" ' clearing text box for next entry txtSales.SetFocus ' setting focus back to the text box for next entry End Sub Private Function curComputePercent(sngBase As Single, sngPercent As Single) As Currency curComputePercent = sngBase * sngPercent End Function