469,643 Members | 1,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,643 developers. It's quick & easy.

Mathmatic record problems...

Hi,

I have the following piece of code which is ment to do a
couple of calculations for me, however for some reason
tmprs("disc") returns some strange results.

If I enter a value of 10 for tmprs("disc") it is fine but
if I enter a second value for tmprs("disc") it doubles my
value. E.G. if I enter 20 the result is 2020

Why and how do I fix it???

An example of response.write statement might look like
this:

0
10
2020

Please help!
Thanks

...:: CODE ::..

if not (tmprs.eof and tmprs.bof) then
tmprs.movefirst
totalcost = 0
totaldisc = 0
grandtotal = 0
while not tmprs.eof
response.write (totaldisc)
response.write ("<BR>")
response.write (tmprs("disc"))
totalcost = totalcost + (tmprs("Quantity") * tmprs
("UnitCost"))
totaldisc = (totalcost / 100 * (totaldisc + tmprs
("disc")))
tmprs.movenext
wend
totaltax = ((totalcost-totaldisc)/100) * TaxAmount
grandtotal = (totalcost + totaltax + numchk(rs
("ShipCost")) + numchk(rs("SurCharge"))) - totaldisc
'error correction
On Error Resume Next
usgrandtotal = ((totalcost/exrate) + (totaltax/exrate) +
(numchk(rs("ShipCost")/exrate)) + (numchk(rs
("SurCharge")/exrate))) - (totaldisc/exrate)
If Err.Number <> 0 Then

Else
Jul 19 '05 #1
1 1255
Look up Cint(), Clng(), CDbl() and CSng() at
http://www.devguru.com/Technologies/...functions.html

You should convert your input to a known numeric type.

Mike
"MyaTiX" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hi,

I have the following piece of code which is ment to do a
couple of calculations for me, however for some reason
tmprs("disc") returns some strange results.

If I enter a value of 10 for tmprs("disc") it is fine but
if I enter a second value for tmprs("disc") it doubles my
value. E.G. if I enter 20 the result is 2020

Why and how do I fix it???

An example of response.write statement might look like
this:

0
10
2020

Please help!
Thanks

..:: CODE ::..

if not (tmprs.eof and tmprs.bof) then
tmprs.movefirst
totalcost = 0
totaldisc = 0
grandtotal = 0
while not tmprs.eof
response.write (totaldisc)
response.write ("<BR>")
response.write (tmprs("disc"))
totalcost = totalcost + (tmprs("Quantity") * tmprs
("UnitCost"))
totaldisc = (totalcost / 100 * (totaldisc + tmprs
("disc")))
tmprs.movenext
wend
totaltax = ((totalcost-totaldisc)/100) * TaxAmount
grandtotal = (totalcost + totaltax + numchk(rs
("ShipCost")) + numchk(rs("SurCharge"))) - totaldisc
'error correction
On Error Resume Next
usgrandtotal = ((totalcost/exrate) + (totaltax/exrate) +
(numchk(rs("ShipCost")/exrate)) + (numchk(rs
("SurCharge")/exrate))) - (totaldisc/exrate)
If Err.Number <> 0 Then

Else

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Wes Brooks | last post: by
3 posts views Thread by rn5a | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.