In Exercise 26 & 28, rewrite the program with the output performed by a call to
ID: 638364 • Letter: I
Question
In Exercise 26 & 28, rewrite the program with the output performed by a call to a Sub procedure.
26. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
'Greet a friend
Dim name As String = "Jack"
txtOutput.Text = "Hi, " & name
End Sub
28. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim city As String, salary As Double
1stOutput. Items.Clear ()
city = "San Jose"
salary = 83089
1stOutput.Items.Add ("In2008, the average salary for " & city & " residents was " & FormatCurrency (salary, 0) & ".")
city = "Hartford"
salary = 46000
1stOutput.Items.Add ("In 2008, the average salary for " & city & " residents was " & FormatCurrency (salary, 0) & ".")
End Sub
Explanation / Answer
Plz try out the codes below..and let me know if its working fine!!! thanx
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
FirstPart()
Dim city As String, salary As Double
city = "Hartford"
salary = 46000
lstOutput.Items.Add("In 2008, the average salary for " & city & " residents was " & FormatCurrency(salary, 0) & ".")
End Sub
Sub FirstPart()
Dim name As String = "Jack"
txtOutput.Text = "Hi, " & name
SecondPart()
End Sub
Sub SecondPart()
Dim city As String, salary As Double
lstOutput.Items.Clear()
city = "San Jose"
salary = 83089
lstOutput.Items.Add("In 2008, the average salary for " & city & " residents was " & FormatCurrency(salary, 0) & ".")
End Sub