CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2009
    Posts
    1

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    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.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2009
    Location
    Kuwait
    Posts
    170

    Re: System.OverflowException (Please Help!)

    Quote Originally Posted by brian1420 View Post
    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.
    If i helped you, Please rate me

    Visit http://www.octopusplus.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured