Results 1 to 6 of 6

Thread: Overflow error

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Canada!
    Posts
    51

    Overflow error

    Just a simple problem for all you experts out there, but I sure can't fix this.....

    the problem is I created a basic calculator, but when I enter numbers in that are greater then 4 digits long Iget a "Overflow error".

    Any help is appreciated!

  2. #2
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    For a calculator you should probably is doubles as your data type. What are you using now?

  3. #3

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Canada!
    Posts
    51
    as integer

  4. #4
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Can you post the code that is giving you the problem?

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2002
    Location
    Canada!
    Posts
    51
    here the code.....

    Private Sub Command1_Click()
    'assign varibles
    Dim one As Integer
    Dim two As Integer
    'Define Varibles
    one = Text1.Text
    two = Texttwo.Text
    ' display answer
    Debug.Print one + two
    MsgBox one + two
    End Sub

    Private Sub Command2_Click()
    'assign varibles
    Dim one As Integer
    Dim two As Integer
    'Define Varibles
    one = Text1.Text
    two = Texttwo.Text
    ' display answer
    Debug.Print one + two
    MsgBox one - two
    End Sub

    Private Sub Command3_Click()
    'assign varibles
    Dim one As Integer
    Dim two As Integer
    'Define Varibles
    one = Text1.Text
    two = Texttwo.Text
    ' display answer
    Debug.Print one + two
    MsgBox one * two
    End Sub

    Private Sub Command4_Click()
    'assign varibles
    Dim one As Integer
    Dim two As Integer
    'Define Varibles
    one = Text1.Text
    two = Texttwo.Text
    ' display answer
    Debug.Print one + two
    MsgBox one / two
    End Sub

    Private Sub Command5_Click()
    'assign varibles
    Dim one As Integer
    'Define Varibles
    one = Text1.Text
    ' display answer
    Debug.Print one ^ 2
    MsgBox one ^ 2
    End Sub
    http://www.aom.rtsgamer.com
    "tragedy is when I cut my finger, Comedy is when I fall into an open man-hole and die."
    Newbiest of the VB Newbs!
    HTML, VB Newbie

  6. #6
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141
    Your problem is you are using integers. Unless the value you are entering is between -32,768 and 32,767 you will get an overflow error. Try changing your data type to single or double.

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