Expand|Select|Wrap|Line Numbers
- rivate Sub btnUp_Click(sender As Object, e As EventArgs) Handles btnUp.Click
- Dim intCount As Integer
- Dim intHours As Integer = 1
- Dim intMilesPerHour As Integer
- Dim strInput As String
- strInput = InputBox("What is the speed in miles-per-hour?", "Enter Speed")
- If Not Integer.TryParse(strInput, intMilesPerHour) Then
- MsgBox("Must enter a numeric value")
- Exit Sub
- End If
- strInput = InputBox("What is the amount of time in hours?" & intCount.ToString(), "Enter Time")
- If Not Integer.TryParse(strInput, intHours) Then
- MsgBox("Must enter a numeric value")
- Exit Sub
- End If
- lstOutput.Items.Add("Vehicle Speed: " & intMilesPerHour.ToString() & " MPH")
- lstOutput.Items.Add("Time Traveled: " & intHours.ToString() & " Hour(s)")
- lstOutput.Items.Add("Hour(s)" & " " & "Distance Traveled")
- lstOutput.Items.Add("----------------------------------------")
- For intCount = 1 To intHours
- lstOutput.Items.Add(intCount & " " & (intCount * intMilesPerHour))
- Next
- lstOutput.Items.Add("Total Distance: " & intMilesPerHour * intHours)
- End Sub
- Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
- Me.Close()
- End Sub
- Private Sub btnDown_Click(sender As Object, e As EventArgs) Handles btnDown.Click
- Dim intCount As Integer
- Dim intHours As Integer = 1
- Dim intMilesPerHour As Integer
- Dim strInput As String
- strInput = InputBox("What is the speed in miles-per-hour?", "Enter Speed")
- If Not Integer.TryParse(strInput, intMilesPerHour) Then
- MsgBox("Must enter a numeric value")
- Exit Sub
- End If
- strInput = InputBox("What is the amount of time in hours?" & intCount.ToString(), "Enter Time")
- If Not Integer.TryParse(strInput, intHours) Then
- MsgBox("Must enter a numeric value")
- Exit Sub
- End If
- lstOutput.Items.Add("Hour(s)" & " " & "Distance Traveled")
- lstOutput.Items.Add("Vehicle Speed: " & intMilesPerHour.ToString() & " MPH")
- lstOutput.Items.Add("Time Traveled: " & intHours.ToString() & " Hour(s)")
- lstOutput.Items.Add("----------------------------------------")
- For intCount = intHours To 1
- lstOutput.Items.Add(intCount & " " & (intCount * intMilesPerHour))
- Next
- lstOutput.Items.Add("Total Distance: " & intMilesPerHour * intHours)
- End Sub
- End Class