System.OverflowException (Please Help!)
When I Run my app, I get a pop up box saying this 'Arithmetic operation resulted in an overflow'. Here is the code;
Try
FSUIPCConnection.Process()
' OK so display the string
' With strings the DLL automatically handles the
' ASCII/Unicode conversion and deals with the
' zero terminators.
FuelTankLCapacity.Value.ToString("F1")
Dim LeftTotalFuel As Integer = (FuelTankLCapacity.Value * 8388608) / LeftTank.Value
Me.Label8.Text = LeftTotalFuel
Catch ex As Exception
MessageBox.Show(ex.Message, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Can i get a bit of help of how to fix this issue? Thanks
Re: System.OverflowException (Please Help!)
You are posting in the wrong forum, for one.
You can't do arithmetic on STRING data. You'd need to convert the type to something that the cpu can add.
Re: System.OverflowException (Please Help!)
Quote:
Originally Posted by
brian1420
When I Run my app, I get a pop up box saying this 'Arithmetic operation resulted in an overflow'. Here is the code;
Try
FSUIPCConnection.Process()
' OK so display the string
' With strings the DLL automatically handles the
' ASCII/Unicode conversion and deals with the
' zero terminators.
FuelTankLCapacity.Value.ToString("F1")
Dim LeftTotalFuel As Integer = (FuelTankLCapacity.Value * 8388608) / LeftTank.Value
Me.Label8.Text = LeftTotalFuel
Catch ex As Exception
MessageBox.Show(ex.Message, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Can i get a bit of help of how to fix this issue? Thanks
check these two lines
Code:
FuelTankLCapacity.Value.ToString("F1")
Dim LeftTotalFuel As Integer = (FuelTankLCapacity.Value * 8388608) / LeftTank.Value
first you are getting a string value, next use double instead of integer.