By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

How do I get this to work from Highest to lowest?

P: 11
all I am getting is the total distance in my list box instead of showing hours and miles from highest to lowest what am I missing or not doing correctly?

Expand|Select|Wrap|Line Numbers
  1. rivate Sub btnUp_Click(sender As Object, e As EventArgs) Handles btnUp.Click
  2.         Dim intCount As Integer
  3.         Dim intHours As Integer = 1
  4.         Dim intMilesPerHour As Integer
  5.         Dim strInput As String
  6.  
  7.  
  8.         strInput = InputBox("What is the speed in miles-per-hour?", "Enter Speed")
  9.  
  10.         If Not Integer.TryParse(strInput, intMilesPerHour) Then
  11.             MsgBox("Must enter a numeric value")
  12.  
  13.             Exit Sub
  14.  
  15.         End If
  16.         strInput = InputBox("What is the amount of time in hours?" & intCount.ToString(), "Enter Time")
  17.         If Not Integer.TryParse(strInput, intHours) Then
  18.             MsgBox("Must enter a numeric value")
  19.  
  20.             Exit Sub
  21.  
  22.         End If
  23.  
  24.  
  25.         lstOutput.Items.Add("Vehicle Speed: " & intMilesPerHour.ToString() & " MPH")
  26.  
  27.         lstOutput.Items.Add("Time Traveled: " & intHours.ToString() & " Hour(s)")
  28.  
  29.         lstOutput.Items.Add("Hour(s)" & "     " & "Distance Traveled")
  30.  
  31.         lstOutput.Items.Add("----------------------------------------")
  32.         For intCount = 1 To intHours
  33.             lstOutput.Items.Add(intCount & "        " & (intCount * intMilesPerHour))
  34.  
  35.         Next
  36.  
  37.         lstOutput.Items.Add("Total Distance: " & intMilesPerHour * intHours)
  38.  
  39.     End Sub
  40.  
  41.     Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
  42.         Me.Close()
  43.  
  44.     End Sub
  45.  
  46.     Private Sub btnDown_Click(sender As Object, e As EventArgs) Handles btnDown.Click
  47.         Dim intCount As Integer
  48.         Dim intHours As Integer = 1
  49.         Dim intMilesPerHour As Integer
  50.         Dim strInput As String
  51.  
  52.  
  53.         strInput = InputBox("What is the speed in miles-per-hour?", "Enter Speed")
  54.  
  55.         If Not Integer.TryParse(strInput, intMilesPerHour) Then
  56.             MsgBox("Must enter a numeric value")
  57.  
  58.             Exit Sub
  59.  
  60.         End If
  61.         strInput = InputBox("What is the amount of time in hours?" & intCount.ToString(), "Enter Time")
  62.         If Not Integer.TryParse(strInput, intHours) Then
  63.             MsgBox("Must enter a numeric value")
  64.  
  65.             Exit Sub
  66.  
  67.         End If
  68.         lstOutput.Items.Add("Hour(s)" & "     " & "Distance Traveled")
  69.  
  70.         lstOutput.Items.Add("Vehicle Speed: " & intMilesPerHour.ToString() & " MPH")
  71.  
  72.         lstOutput.Items.Add("Time Traveled: " & intHours.ToString() & " Hour(s)")
  73.         lstOutput.Items.Add("----------------------------------------")
  74.         For intCount = intHours To 1
  75.             lstOutput.Items.Add(intCount & "        " & (intCount * intMilesPerHour))
  76.  
  77.         Next
  78.  
  79.         lstOutput.Items.Add("Total Distance: " & intMilesPerHour * intHours)
  80.  
  81.  
  82.     End Sub
  83. End Class
Mar 27 '16 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.