C
Charlie Brookhart
I have a program (posted below) that is supposed to take liters, which is
the user input, and convert it to pints and gallons. The pints and gallons
are displayed in a read only textbox. I don't understand how to fix the
problem.
'declaring variables
Dim totalLiters As Double = Convert.ToDouble(txtLiters.Text)
Dim totalPints As Double = Convert.ToDouble(txtPints.Text)
Dim totalGallons As Double = Convert.ToDouble(txtGallons.Text)
'assigning text box values to variables
totalLiters = txtLiters.Text
totalPints = txtPints.Text
totalGallons = txtGallons.Text
'performing calculations
txtPints.Text = totalLiters * 2.1133
txtGallons.Text = totalLiters * 0.26
Runtime error message:
An unhandled exception of type 'System.FormatException' occurred in
mscorlib.dll
Additional information: Input string was not in a correct format.
the user input, and convert it to pints and gallons. The pints and gallons
are displayed in a read only textbox. I don't understand how to fix the
problem.
'declaring variables
Dim totalLiters As Double = Convert.ToDouble(txtLiters.Text)
Dim totalPints As Double = Convert.ToDouble(txtPints.Text)
Dim totalGallons As Double = Convert.ToDouble(txtGallons.Text)
'assigning text box values to variables
totalLiters = txtLiters.Text
totalPints = txtPints.Text
totalGallons = txtGallons.Text
'performing calculations
txtPints.Text = totalLiters * 2.1133
txtGallons.Text = totalLiters * 0.26
Runtime error message:
An unhandled exception of type 'System.FormatException' occurred in
mscorlib.dll
Additional information: Input string was not in a correct format.