You are on page 1of 3

1/29/2017 www.minich.com/education/racc/visualbasic/cis230ch5/frmcis230ch5demo3form1.

txt

VERSION5.00
BeginVB.FormForm1
Caption="Form1"
ClientHeight=6645
ClientLeft=60
ClientTop=345
ClientWidth=6975
LinkTopic="Form1"
ScaleHeight=6645
ScaleWidth=6975
StartUpPosition=3'WindowsDefault
BeginVB.CommandButtoncmdCalculateSalesTax
Caption="&CalculateSalesTax"
Height=495
Left=4320
TabIndex=9
Top=2640
Width=1215
End
BeginVB.TextBoxtxtPrice
Height=375
Left=4320
TabIndex=0
Top=1080
Width=1095
End
BeginVB.FrameFrame1
Caption="States"
Height=3135
Left=360
TabIndex=1
Top=840
Width=1815
BeginVB.OptionButtonoptDE
Caption="&Delaware"
Height=255
Left=240
TabIndex=6
Top=2520
Width=1335
End
BeginVB.OptionButtonoptNY
Caption="&NewYork"
Height=255
Left=240
TabIndex=5
Top=2040
Width=1335

http://www.minich.com/education/racc/visualbasic/cis230ch5/frmcis230ch5demo3form1.txt 1/3
1/29/2017 www.minich.com/education/racc/visualbasic/cis230ch5/frmcis230ch5demo3form1.txt

End
BeginVB.OptionButtonoptMD
Caption="&Maryland"
Height=375
Left=240
TabIndex=4
Top=1440
Width=1455
End
BeginVB.OptionButtonoptOH
Caption="&Ohio"
Height=255
Left=240
TabIndex=3
Top=960
Width=1455
End
BeginVB.OptionButtonoptPA
Caption="&Pennsylvania"
Height=255
Left=240
TabIndex=2
Top=480
Value=1'True
Width=1455
End
End
BeginVB.LabelLabel1
Caption="SalesTaxis:"
Height=255
Left=3000
TabIndex=10
Top=1920
Width=1095
End
BeginVB.LabelLabel2
Caption="EnterPrice:"
Height=255
Left=3000
TabIndex=8
Top=1200
Width=975
End
BeginVB.LabellblSalesTax
Caption="0"
Height=255
Left=4320
TabIndex=7
Top=1920
http://www.minich.com/education/racc/visualbasic/cis230ch5/frmcis230ch5demo3form1.txt 2/3
1/29/2017 www.minich.com/education/racc/visualbasic/cis230ch5/frmcis230ch5demo3form1.txt

Width=615
End
End
AttributeVB_Name="Form1"
AttributeVB_GlobalNameSpace=False
AttributeVB_Creatable=False
AttributeVB_PredeclaredId=True
AttributeVB_Exposed=False
'Ch5DemoProgram#3
'Mr.Minich
'Thisprogramdemonstratestheuseofageneralfunctionprocedure.It'susemakestheprogrameasierto
'understandanditreusescodesincethepossibleverycomplicatedmathematicalcomputationthatis
'performedwithincurComputePercentdoesnothavetoberepeatedintheIf/ElseIfstatement5times.
'Also,thisfunctionisIDENTICALtocurComputePercentinCh.5DemoProgram#2showingthatyoucan
'reusefunctionsthatyouwroteearlierinyourprogrammingcareer.

OptionExplicit

PrivateSubcmdCalculateSalesTax_Click()
IfoptPAThen
lblSalesTax=curComputePercent(txtPrice,0.06)'PAhas6%salestax
ElseIfoptOHThen
lblSalesTax=curComputePercent(txtPrice,0.05)'OHhas5%salestax
ElseIfoptMDThen
lblSalesTax=curComputePercent(txtPrice,0.8)'MDhas80%salestax
ElseIfoptNYThen
lblSalesTax=curComputePercent(txtPrice,0.075)'NYhas7.5%salestax
ElseIfoptDEThen
lblSalesTax=curComputePercent(txtPrice,0)'DEhasnosalestax
EndIf

txtPrice=""'clearingtextboxfornextentry
txtPrice.SetFocus'settingfocusbacktothetextboxfornextentry
EndSub

PrivateFunctioncurComputePercent(sngBaseAsSingle,sngPercentAsSingle)AsCurrency
curComputePercent=sngBase*sngPercent
EndFunction

http://www.minich.com/education/racc/visualbasic/cis230ch5/frmcis230ch5demo3form1.txt 3/3

You might also like