189
158
I
ntr
od
u
ci
n
g
CheckBox
e
s
a
n
d
M
e
ss
age
D
ialog
s
Tutorial 8
simplyvb2008_08.fm
February 1, 2008 4:37 pm
© 2008 by Deitel & Associates, Inc. All Rights Reserved.
8.2 D
e
si
g
nin
g
th
e
Dental Payment
A
pp
li
ca
ti
o
n
Recall that pseudocode is an informal language that helps programmers develop
algorithms. The following pseudocode describes the basic operation of the Dental
Payment application, which runs when the user clicks Calculate:
When the user clicks the Calculate Button
Clear previous output
If user has not entered a patient name or has not selected any CheckBoxes
Display message in dialog
Else
Initialize the total to zero
If “Cleaning” CheckBox is selected
Add cost of a cleaning to the total
If “Cavity Filling” CheckBox is selected
Add cost of receiving a cavity filling to the total
If “X-Ray” CheckBox is selected
Add cost of receiving an x-ray to the total
Format total to be displayed as currency
Display total
Now that you’ve test-driven the Dental Payment application and studied its
pseudocode representation, you’ll use an ACE table to help you convert the
pseudocode to Visual Basic. Figure 8.6 lists the actions, controls and events that will
help you complete your own version of this application. Data is input using a
Text-
Box
(
nameTextBox
) and
CheckBox
es (
cleanCheckBox
,
cavityCheckBox
and
xrayCheckBox
). Output is displayed in
Label
totalResultLabel
when a
Button
(
calculateButton
) is clicked.
A
c
ti
o
n
/
C
o
ntr
o
l
/
Ev
e
nt
(ACE)
Tab
l
e
f
o
r th
e
Dental Payment
A
pp
li
ca
ti
o
n
A
c
ti
o
n
C
o
ntr
o
l
/
Cl
a
ss
/
O
b
j
ec
t
Ev
e
nt
Label all the application’s controls
titleLabel
,
nameLabel
,
totalLabel
,
cleanCostLabel
,
fillingCostLabel
,
xrayCostLabel
Application
is run
calculateButton
Click
Clear previous output
totalResultLabel
If user has not entered a patient name or has
not selected any CheckBoxes
nameTextBox,
cleanCheckBox
,
cavityCheckBox
,
xrayCheckBox
Display message in dialog
MessageBox
Else
Initialize the total to zero
If “Cleaning” CheckBox is selected
Add cost of a cleaning to the total
cleanCheckBox
If “Cavity Filling” CheckBox is selected
Add cost of receiving a cavity filling to
the total
cavityCheckBox
Figure 8.6
ACE t
able
f
o
r
Dental
Payment
applica
t
io
n. (P
a
rt 1
o
f 2.)