|
-
August 5th, 2002, 03:18 AM
#1
Numbers that are larger then 2147483647 always get a # in my code
Hi,
When i type numbers that are larger then 2147483647(The long limit) ther always appears a # sign, why is that and how can i get this away. I would like to do this simple code:
msgbox cdec(2147483648)
but when i type this i get the following in my code if i change line:
MsgBox CDec(2147483648#)
Thanx
-
August 5th, 2002, 04:02 AM
#2
Upper limit
I don't know why this happens, as you said it is the long upper limit. Longs have 4 bytes allocated to them, whereas Doubles have 8 and Decimals have 14. Making the decimal maximum about 8*10^23 or 79,228,162,514,264,337,593,543,950,335. To actually find out how to get round this, or to see if your doing anything wrong, i'd need to see the code your writing.
Hot me back with the code and ill see what i can do.
Finite
"If a cat always lands on its feet, and a peice of bread always lands butter side down, if you strap a peice of bread butter side up to the back of a cat, will it hover?"
-
August 5th, 2002, 04:22 AM
#3
The code is not realy special. it's a small program that checks a banking number. So if a user enters the number 833-4514319-03 the program has to say if the code is correct (if you divide the first 10 figures by 97 the rest must be 03)
So this is my code:
if CDec(Left(Text1, 3) & Mid(Text1, 5, 7)) mod 97 = cint(right(text1,2)) then
msgbox "OK"
else msgbox "Not OK"
end if
And even this simple thing does not work:
msgbox CDec(Left(Text1, 3) & Mid(Text1, 5, 7)) mod 97
What well works is:
CDec(Left(Text1, 3) & Mid(Text1, 5, 7)) / 97
And if you type in your code window the number 8334514319, vb adds automaticly the # sign when you goto another line.
I find it verry strange.
Thanx 4 your reply
-
August 5th, 2002, 04:34 AM
#4
Right. After a little testing, i see you problem. What its the fundamental difference with the first two sections of code, and the last one.
Answer? The Mod operator. You get an overflow error with the mod operator because it is not desgined for that kind of number. Offhand, I cant think of how you could do it otherwise.
My best suggestion would be to do a Floating Point division of the bank account number by 97 into a double variable. Then check to see if the 1st 2 digits after the decimal point are equal to '03' for example. If you have any problems, hit me back.
Finite
"If a cat always lands on its feet, and a peice of bread always lands butter side down, if you strap a peice of bread butter side up to the back of a cat, will it hover?"
-
August 5th, 2002, 04:37 AM
#5
#$%&
Oh yeah, just incase you want to know.
# is the type declaration character for a Double Value.
Just like $ is for a string and & for a long.
Finite
"If a cat always lands on its feet, and a peice of bread always lands butter side down, if you strap a peice of bread butter side up to the back of a cat, will it hover?"
-
August 5th, 2002, 06:54 AM
#6
Ok, i found a different way to do this, did not know that the mod function did'nt allow figures larger than long.
Thanx for youre help
-
August 5th, 2002, 06:57 AM
#7
well if i'm not mistaken all you want to do is take a number and put it in a msgbox right? so, just typecast it:
msgbox Str(number)
hope this helps
- nc
"In a world without walls and barriers, what need is there for windows and gates!" - a mac ad
"What was the best thing before sliced bread and when did sliced bread go out of existence?" - me
"Software is like sex, it's better when it's free." - Linus Torvalds <- gotten from Andreas Masur
Live Penguine! - Tux the linux mascot
Vivez le penguine!, ¡Viva en penguine!, Lang lebe der Pinguin!, Viva no penguine!, Viva sul penguine!
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
|