Question
Chapter 5 Section 2: Sub Procedures, Part 1 In Exercises 3 through 19, determine the output displayed when the button is clicked. (Check the assumptions
Chapter 5 Section 2: Sub Procedures, Part 1
In Exercises 3 through 19, determine the output displayed when the button is clicked. (Check the assumptions when listed at the end of the exercise)
3. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim Color As String
Color = InputBox(What is your favorite color?)
Flattery(color)
End Sub
Sub Flattery(color As String)
txtOutput.Text = You look dashing in & color & .
End Sub
(Assume the response is blue)
5. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim hours As Double
hours = 24
Minutes(60 * hours)
End Sub
Sub Minutes(num As Double)
txtOutput.Text = num & minutes in a day
End Sub
7. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Question()
Answer()
End Sub
Sub Answer()
lstOutput.Items.Add(Because they were invented in the northern)
lstOutput.Items.Add(hemisphere where sundials go clockwise)
End Sub
Sub Question()
lstOutput.Items.Add(Why do clocks run clockwise?)
lstOutput.Items.Add()
End Sub
9. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Beginning of Tale of Two Cities
Times(best)
Times(worst)
End Sub
Sub Times(word As String)
Display sentence
lstOutput.Items.Add(It was the & word & of times
End Sub
11. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
The fates of Henry the Eighths six wives
CommonFates()
lstOutput.Items.Add(died)
CommonFates()
lstOutput.Items.Add(survived)
End Sub
Sub CommonFates()
The most common fates
lstOutput.Items.Add(divorced)
lstOutput.Items.Add(beheaded)
End Sub
13. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
HowMany(24)
lstOutput.Items.Add(a pie)
End Sub
Sub HowMany(num As Integer)
What(num)
lstOutput.Items.Add(baked in)
End Sub
Sub What(num As Integer)
lstOutput.Items.Add(num & blackbirds)
End Sub
15. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim word As String, num As Integer
Word = Visual Basic
Num = 6
FirstPart(word, num)
End Sub
Sub FirstPart(term As String, digit As Integer)
txtOutput.Text = The first & digit & letters are &
term.Substring(0, digit) & .
End Sub
17. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim cost As Double = 250
DisplayBill(cost, ShippingCost(cost))
End Sub
Function ShippingCost(costOfGoods As Double) As Double
Select Case costOfGoods
Case Is < 100
Return 10
Case Is < 500
Return 15
Case Else
Return 20
End Select
End Function
Sub DisplayBill(cost As Double, addedCost As Double)
lstOutput.Items.Add(Cost: & cost.ToString(C))
lstOutput.Items.Add(ShippingCost: & addedCost.ToString(C))
lstOutput.Items.Add(Total cost: & (cost + addedCost).ToString(C))
End Sub
19. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim grade = CDbl(InputBox(What is your numeric grade?, Grade))
ShowResult(grade)
End Sub
Sub ShowResult(grade As Double)
If (grade < 0 ) Or (grade > 100) Then
MessageBox.Show(Improper grade)
Exit Sub
End If
If PassedExam(grade) Then
txtOutput.Text = You passed with a grade of & grade & .
Else
txtOutput.Text = You failed the exam.
End If
End Sub
(Assume the response is 92.)
In Exercise 21 find the errors.
21. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim n As Integer = 5
Alphabet()
End Sub
Sub Alphabet(n As Integer)
txtOutput.Text = abcdefghijklmnopqrstuvwxyz.Substring(0, n)
End Sub
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started