M
Mike & Dyan
I am making a Mileage Calculator for work to keep track of mileage on my
car. I think I am missing something. In the answer box I only want 2
decimal places to right to show. For some reason I get it to work. Here is
my code.
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCalculate.Click
Dim decMilesDriven As Decimal
Dim decgallonsofGas As Decimal
Dim decMPG As Decimal
decMilesDriven = Val(tbMilesDriven.Text)
decgallonsofGas = Val(tbGallonsofGas.Text)
decMPG = decMilesDriven / decgallonsofGas
lblMPGResults.Text = String.Format("{0:F}", decMPG & " MPG")
End Sub
car. I think I am missing something. In the answer box I only want 2
decimal places to right to show. For some reason I get it to work. Here is
my code.
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCalculate.Click
Dim decMilesDriven As Decimal
Dim decgallonsofGas As Decimal
Dim decMPG As Decimal
decMilesDriven = Val(tbMilesDriven.Text)
decgallonsofGas = Val(tbGallonsofGas.Text)
decMPG = decMilesDriven / decgallonsofGas
lblMPGResults.Text = String.Format("{0:F}", decMPG & " MPG")
End Sub