eval (CInt((([10000]/([4500]+[500]))*1000)*100))

1. Member
Join Date
Dec 1969
Posts
36

## eval (CInt((([10000]/([4500]+[500]))*1000)*100))

Hi,<BR><BR>I am having trouble evaluating a formula. I recieve the formula via Request.Querystring ("fm") and need to return the answer. I have tried eval but it gives an overflow error. Is there other way to find the answer to "CInt((([10000]/([4500]+[500]))*1000)*100)"<BR><BR>Thanks<BR><BR>Leah

2. oli
Senior Member
Join Date
Dec 1969
Posts
3,961

## RE: eval (CInt((([10000]/([4500]+[500]))*1000)*100

&#060;% <BR>Num1 = 4500+500<BR>Num2 = 10000 / Num1<BR>Num3 = Num2*1000<BR>Num4 = Num3*100<BR>Response.write Num4<BR>%&#062;

3. Member
Join Date
Dec 1969
Posts
36

Good Answer, but the formula comes from a query string and can be anything from 1+1 to something quite complicated. It cannot be separated like that as I do not know what the formula will be.

4. oli
Senior Member
Join Date
Dec 1969
Posts
3,961

Replace the square brackets and remove the CInt:<BR>&#060;% <BR>Response.write ((10000 / 4500+500)*1000)*100<BR>%&#062;

5. Member
Join Date
Dec 1969
Posts
36

but what id they need the cint, the user might enter 56.543 or the answer might be a decimal, and in that case it needs to be converted.

6. Senior Member
Join Date
Dec 1969
Posts
16,931

## Remove the "C":

CInt():<BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctcint.asp<BR>Returns an expression that has been converted to a Variant of subtype Integer.<BR><BR>Int():<BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctint.asp<BR>Returns the integer portion of a number.<BR><BR>If the value you&#039;re CInt()-ing is greater than the maximum for an integer (32000-ish), then you&#039;ll get an overflow. However, you CAN Int() something greater than the maximum of an integer, I believe.<BR><BR>Try it, anyway :-)<BR><BR>Craig.

7. Member
Join Date
Dec 1969
Posts
36

IIF(isnull([C]),Null,Int(([A]/([B]+[C]))*1000)*100)<BR><BR>That creates an overflow.

8. Senior Member
Join Date
Dec 1969
Posts
208

Howdy Leah,<BR><BR>Have you tried using CLng instead of CInt? <BR>CInt: 16 bit integer (32,767 to -32,768)<BR>CLng: 32 bit integer (2,147,483,647 to -2,147,483,648)<BR><BR>Regardless of any built-in method which you use, you will always be able to enter numbers big enough to overflow. But CLng may be big enough for your purposes.<BR><BR>Hope this helps.

9. Senior Member
Join Date
Dec 1969
Posts
96,118

## What are the [...] for????

Those aren&#039;t legit, in any case.<BR><BR>As for whether it creates an overflow: Well, doesn&#039;t that depend on what the values of A, B, and C are????<BR><BR>If it&#039;s an overflow, so be it. Tell the user and get on with it.<BR><BR>

10. Senior Member
Join Date
Dec 1969
Posts
96,118

## Yes, but...

...if you use INT instead of either CINT or CLNG, then there&#039;s no practical limit. It&#039;s kind of meaningless to do INT( 7E+87 ) but you can do it.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•