Asked by darlene
Direction: Write a program that displays the output shown in a list box. The last two lines of the output should be displayed by one or more Sub procedures using data passed by variables from an event procedure.
Problem One: Assume that the current date is 12/31/2010, the label for txtBox reads “What is your date of birth?”, and the user enters 2/3/1984 into txtBox before btnDisplay is clicked.
You are now 26 years old.
You have lived for 9824 days.
Direction: Determine the output displayed when the button is clicked
Problem Two:
Private Sub btnDisplay_Click(…) Handles btnDisplay.Click
‘Rule of 72
Dim p As Double
p = CDbl (txtPopGr.Text) ‘Population growth as a percent
txtOutput.Text = “The population will double in “ &
DoubleTime(p) & “ years."
End Sub
Function DoublingTime(ByVal x As Double) As Double
‘Number of cars that can be parked
Return 100 * x
End Function
Problem Three:
Private Sub btnDisplay_Click(…) Handles btnDisplay.Click
Dim d As Date = #12/4/2011#
txtOutput.Text = MonthAbbr(d)
End Sub
Funcion MonthAbbr(ByVal d As Date) As String
Dim str As String = FormatDateTime(d, DateFormat.LongDate)
Dim n As Integer = str.IndexOf(“ “)
Return str.Substring(n + 1, 3)
End Function
Problem One: Assume that the current date is 12/31/2010, the label for txtBox reads “What is your date of birth?”, and the user enters 2/3/1984 into txtBox before btnDisplay is clicked.
You are now 26 years old.
You have lived for 9824 days.
Direction: Determine the output displayed when the button is clicked
Problem Two:
Private Sub btnDisplay_Click(…) Handles btnDisplay.Click
‘Rule of 72
Dim p As Double
p = CDbl (txtPopGr.Text) ‘Population growth as a percent
txtOutput.Text = “The population will double in “ &
DoubleTime(p) & “ years."
End Sub
Function DoublingTime(ByVal x As Double) As Double
‘Number of cars that can be parked
Return 100 * x
End Function
Problem Three:
Private Sub btnDisplay_Click(…) Handles btnDisplay.Click
Dim d As Date = #12/4/2011#
txtOutput.Text = MonthAbbr(d)
End Sub
Funcion MonthAbbr(ByVal d As Date) As String
Dim str As String = FormatDateTime(d, DateFormat.LongDate)
Dim n As Integer = str.IndexOf(“ “)
Return str.Substring(n + 1, 3)
End Function
Answers
There are no human answers yet.
There are no AI answers yet. The ability to request AI answers is coming soon!
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.