Determine the output displayed in the picture box when the command button is clicked:
Private Sub cmdDisplay_Click()
Dim a As Single, b As Single
Let a = Val(InputBox("Enter a number."))
Let b = Val(InputBox("Enter another number."))
If a > b then
Let a = a - 1
Else
Let b = b + 1
End If
Picture1.Print a; b
End Sub
(Assume that the responses are 10 and 9.)
Identify the possible 'logic' error in the following program segment (and also indicate the correction):
Private Sub CmdDisplay_Click()
Dim major As String
major = InputBox("Enter your major")
If major = "Information Management" or "Computer Science" then
picOuput.Print "Yes"
End if
End Sub
In the following program segment, rewrite the code using a Select Case block.
Private Sub cmdDisplay_Click()
dim a as single
if a = 1 then
picOutput.print "lambs"
end if
if a <= 3 and a < 4 then
picOutput.print "eat"
end if
if a = 5 or a > 7 then
picOutput.print "ivy"
end if
end sub
The flowchart in Figure 5.3 (p. 220) calculates New Jersey state income tax. Write a program corresponding to the flowchart. Use Select Case block(s) to implement the set of If blocks.
Do you have any questions, comments or suggestions? If so, please e-mail them to me at jcorlis@luc.edu.
To return to the COMP 125 web site, click here.
To go to my home page, click here.
To go to the home page of Loyola University Chicago, click here.
Jack Corliss
Mathematical and Computer Sciences
Loyola University Chicago
Revised: 20 March 1999