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 cmdCalculateSalesTax Caption = "&Calculate Sales Tax" Height = 495 Left = 4320 TabIndex = 9 Top = 2640 Width = 1215 End Begin VB.TextBox txtPrice Height = 375 Left = 4320 TabIndex = 0 Top = 1080 Width = 1095 End Begin VB.Frame Frame1 Caption = "States" Height = 3135 Left = 360 TabIndex = 1 Top = 840 Width = 1815 Begin VB.OptionButton optDE Caption = "&Delaware" Height = 255 Left = 240 TabIndex = 6 Top = 2520 Width = 1335 End Begin VB.OptionButton optNY Caption = "&New York" Height = 255 Left = 240 TabIndex = 5 Top = 2040 Width = 1335 End Begin VB.OptionButton optMD Caption = "&Maryland" Height = 375 Left = 240 TabIndex = 4 Top = 1440 Width = 1455 End Begin VB.OptionButton optOH Caption = "&Ohio" Height = 255 Left = 240 TabIndex = 3 Top = 960 Width = 1455 End Begin VB.OptionButton optPA Caption = "&Pennsylvania" Height = 255 Left = 240 TabIndex = 2 Top = 480 Value = -1 'True Width = 1455 End End Begin VB.Label Label1 Caption = "Sales Tax is:" Height = 255 Left = 3000 TabIndex = 10 Top = 1920 Width = 1095 End Begin VB.Label Label2 Caption = "Enter Price:" Height = 255 Left = 3000 TabIndex = 8 Top = 1200 Width = 975 End Begin VB.Label lblSalesTax 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 #3 '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. ' Also, this function is IDENTICAL to curComputePercent in Ch. 5 Demo Program #2 showing that you can ' reuse functions that you wrote earlier in your programming career. Option Explicit Private Sub cmdCalculateSalesTax_Click() If optPA Then lblSalesTax = curComputePercent(txtPrice, 0.06) ' PA has 6% sales tax ElseIf optOH Then lblSalesTax = curComputePercent(txtPrice, 0.05) ' OH has 5% sales tax ElseIf optMD Then lblSalesTax = curComputePercent(txtPrice, 0.8) ' MD has 80% sales tax ElseIf optNY Then lblSalesTax = curComputePercent(txtPrice, 0.075) ' NY has 7.5% sales tax ElseIf optDE Then lblSalesTax = curComputePercent(txtPrice, 0) ' DE has no sales tax End If txtPrice = "" ' clearing text box for next entry txtPrice.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