|
-
Jun 6th, 2010, 01:18 PM
#1
Thread Starter
Lively Member
Gas Gauge
I would like to know how to program a "gas gauge" if you will. I know the MPG of our shuttle and the mileage for each shuttle run but I am not sure how to make the gas gauge work. I am using a progress bar for that. Any ideas? Any help would be appreciated.
-
Jun 6th, 2010, 02:39 PM
#2
Re: Gas Gauge
I don't understand the question.
What is the progress bar supposed to show the progress of?
-
Jun 6th, 2010, 03:19 PM
#3
Thread Starter
Lively Member
Re: Gas Gauge
Okay, sorry. I have a Shuttle Van Program that I am working on and I am using a progress bar to simulate a fuel gauge. Whenever a user inserts a new shuttle run I want it to calculate the fuel consumption and show it on the progress bar. How do I do that?
Also, I am having trouble adding the miles to the destination to the mileage on the car. I get 89000.5 and it only does it once for some reason. I am using My.Settings to store mileage and adding to it as each shuttle run is put into the database.
Code:
Try
Dim NewMPG As Decimal
NewMPG = lblMiles.Text + MilesTextBox.Text
lblMiles.Text = NewMPG
My.Settings.Mileage = lblMiles.Text
My.Settings.Save()
lblMiles.Text = "ESTIMATED VEHICLE MILEAGE: " & My.Settings.Mileage
Catch ex As Exception
End Try
-
Jun 6th, 2010, 08:27 PM
#4
Re: Gas Gauge
You are assuming that this:
Code:
NewMPG = lblMiles.Text + MilesTextBox.Text
will automatically convert both strings to numbers for you, which it won't. "1" + "2" is "12", not "3". Additions of strings is concatenation. If you want to add numbers then you need to have numbers. You shouldn't be using the Text of the Label at all because in order to display a number in a Label you must have had a number in the first place, so you should use that. As for the TextBox, you could use a NumericUpDown instead, or you could use Decimal.TryParse to convert the Text of the TextBox.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|