|
-
Mar 23rd, 2002, 06:40 PM
#1
Thread Starter
Member
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!
-
Mar 23rd, 2002, 07:28 PM
#2
For a calculator you should probably is doubles as your data type. What are you using now?
-
Mar 23rd, 2002, 08:25 PM
#3
Thread Starter
Member
-
Mar 23rd, 2002, 08:47 PM
#4
Can you post the code that is giving you the problem?
-
Mar 24th, 2002, 08:45 PM
#5
Thread Starter
Member
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
-
Mar 24th, 2002, 09:05 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|