This topic is locked

Calculations

5/9/2008 9:27:48 PM
ASPRunnerPro General questions
jadach authorDevClub member

I use this code to subtract numeric fields:
// Before record updated

Function BeforeEdit(dict, where, oldvalues,keys,message,inline)
dict("NewBalance") = CInt(dict("PrevBalance"))-CInt(dict("QuantityDispensed"))
BeforeEdit = True
End Function ' BeforeEdit

It ignores decimals. Whole numbers are fine. PLEASE HELP - I REALLY need it to calculate decimals as well!!
Thanks

Sergey Kornilov admin 5/12/2008

Use CDbl() instead of CInt().
More info:

http://www.w3schools.com/VBscript/vbscript_ref_functions.asp

jadach authorDevClub member 5/12/2008

Yes, I emailed support and they said the same thing. Use:
dict("NewBalance") = CDbl(dict("PrevBalance"))-CDbl(dict("QuantityDispensed"))
Works great!! Thank you.

Use CDbl() instead of CInt().

More info:

http://www.w3schools.com/VBscript/vbscript_ref_functions.asp