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!
Printable View
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!
For a calculator you should probably is doubles as your data type. What are you using now?
as integer
Can you post the code that is giving you the problem?
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
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.