473,412 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

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

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
0 1638

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

Similar topics

4
by: James | last post by:
I have a from with 2 fields: Company & Name Depening which is completed, one of the following queries will be run: if($Company){ $query = "Select C* From tblsample Where ID = $Company...
2
by: jason | last post by:
Will this work - dynamic determination of root (local or web host) and consume this in include file anywhere. I am concerned about dynamic construction of virtual absolute include in the consuming...
3
by: Luis | last post by:
I am trying to write a program that checks to see if a fraction is reducable, and to do this both numerator and denominator cannot be tre( prime) will this work? if not can some one fix it up a bit...
3
by: Cool Mentalist | last post by:
function lightUp(light){ light.style.background="yellow" } hello hello2 hello3 etc etc
5
by: Mark Bruno | last post by:
I thought system("PAUSE"); was part of stdlib.h and cstdlib. Then why does this work? : #include <iostream> using namespace std; int main() { cout << "hello, world" << endl;...
44
by: Bamber | last post by:
Why does f get returned ? (compiled with gcc). #include<stdio.h> int func(int a); main() { int f; f=func(7); printf("f=%d",f);
5
by: gabriele | last post by:
Hi, i'm new in this newsgroup, I'm working on a web based managerial software in my company and, for speed-up my work, have created a framework This framework uses the PHP and JAVASCRIPT...
2
by: Mark Cooney | last post by:
Hi Why doesnt this work? <% CatID = dsMain.SelectParameters("fkCatID").ToString%> or <% CatID = Eval("fkCatID") %> Anyone have a solution?
6
by: John | last post by:
Following code belongs to the first field in form B. When I open form B from form A, ctl.Name returns the name of Form's A button which I just clicked. How does this work? I thought when the field...
1
by: Kris tarun | last post by:
I have a table of a retail store which has almost 13000 customers. and i want to write a query for this.. Group products based on their sales patterns. Highest, lowest, and median values. Use...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.