Determine the output displayed when the button is clicked


1. Determine the output displayed when the button is clicked.

Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
‘Triple a number
Dim num As Double = 5
lstOutput.Items.Add(Triple(num))
lstOutput.Items.Add (num)
End Sub
Function Triple(ByVal x As Double) As Double
Dim num As Double = 3
Return num * x
End Function

2. Determine the output displayed when the button is clicked.

Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim states, senators As Double
States = 50
Senators = 2
Senate(states * senators)
End Sub
Sub Senate (ByVal num as Double)
txtBox.Text = "the number of U.S. Senators is " & num
End Sub

3. Find the errors.

Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim word As String, number As Double
word = "seven"
number = 7
Display (word, number)
End Sub
Sub Display(ByVal num As Double, ByVal term As String)
textOutput.Text = num & " " & term
End Sub

4. Rewrite the program so input, processing, and output are each performed by calls to Sub procedures.

Private Sub btnCompute_Click(...) Handles btnCompute.Click
‘Information about trees
Dim num As Integer = 7
Tree = "redwood"
ht = 362
lstBox.Items.Add("The tallest " & tree & " tree in the U. S, is " & ht & & " feet.")
tree = "pine"
ht = 223
lstBox.Items.Add("The tallest " & tree & " tree in the U. S. is " & ht & " feet.")
End Sub

5. Determine the output displayed when the button is clicked.

Private Sub btnDetermine_Click(...) Handles btnDetermine.Click
Dim word As String = ""
Dim num As Integer
GetFacts(word, num)
txtOutput.text = "The first " & num & " letters of " & word & " are " & BegOfWord(word, num) & "."
End Sub
Sub GetFacts(ByRef w As String, ByRef num As Integer)
w = InputBox("enter a word: ")
n = CInt(InputBox("Enter a number less than the length of the word: "))
End Sub
Function BefOfWiord(ByVal word As String, ByVal num As Integer) As String
Return word.Substring(0, num)
End Function
(Assume the two responses are Education and 3.)

6. Determine the output displayed when the button is clicked.

Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim price, markdown, salesTax, finalCost as Double
InputData(price, finalCost)
finalCost = CostOfItem(price, markdown, salesTax)
DisplayOutput(price, finalCost)
End Sub
Sub InputData (ByRef price As Double, ByRef markdown As Double, ByRef salesTax As Double)
Price = CDbl(InputBox("Price of item: ")
Markdown = CDbl (InputBox("Percentage discount: "))
salesTax = CDbl(InputBox("Percentage state sales tax: "))
End Sub
Function CostOfItem(ByVal pr As Double, ByVal md As Double, ByVal st As Double) As Double
Dim reducedPrice, cost As Double
reducedPrice = pr - ((md/100) * pr)
cost = reducedPrice + ((st / 100) * reducedPrice)
Return cost
End Function
(Assume the three responses are 125, 20, and 6)

7. Identify the errors.

Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim word As String
word = InputBox("What is your favorite word?")
txtOutput.Text = "When the word is written twice, " & _
Twice(word) & " letters are used."
End Sub
Function Twice(ByVal w As String) As Integer
'Compute twice the length of a string
Dim len As Integer
Return len = 2 * w.Length

End Function

Request for Solution File

Ask an Expert for Answer!!
Visual Basic Programming: Determine the output displayed when the button is clicked
Reference No:- TGS01089537

Expected delivery within 24 Hours