|
-
July 16th, 2001, 04:12 AM
#1
how to detect an overflow?
hello,
i m creating a calculator in 16 bit. how can i detect an overflow in run time?
ohad
-
July 16th, 2001, 04:28 AM
#2
Re: how to detect an overflow?
one way is to use larger data type to store the result and check for overflow. for instance,
dim i as integer
dim j as integer
dim l as long
l = i + j
if l > 32767 then
'overflow
end
second way, use On Error Goto ....
[vbcode]
On Error Goto ErrorTrap
dim i as integer
dim j as integer
dim k as integer
k = i + j
exit function
ErrorTrap:
'if k overflow, this part of code will be executed ...
HTH
cksiow
http://vblib.virtualave.net - share our codes
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
|