Total figure not accurate?

# Thread: Total figure not accurate?

1. ncw
Senior Member
Join Date
Dec 1969
Posts
614

## Total figure not accurate?

&#060;%<BR>Do While Not rs.EOF<BR>strTotal = rs("qty_issued") * rs("stock_price")<BR>response.write "&#060;tr&#062;&#060;td&#062;" & rs("stock") & "&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & rs("qty") & "&#060;/td&#062;"<BR>response.write "&#060;td&#062;" & formatnumber(strTotal,2) & "&#060;/td&#062;&#060;/tr&#062;"<BR>strGrandTotal = clng(strGrandTotal) + clng(strTotal)<BR>rs.MoveNext<BR>Loop<BR>response. write "&#060;tr&#062;&#060;td&#062;&#060;b&#062;Gran d Total = " & formatnumber(strGrandTotal,2) & "&#060;/b&#062;&#060;/td&#062;&#060;/tr&#062;"<BR>%&#062;<BR><BR>I wonder why my grand total figure not accurate esp the total of cents. Sample<BR>Stock Qty \$<BR>Flyers 600 162.36<BR>chair 1 16.50<BR>Grand total = 178.00<BR><BR>How do I fix this? Thank you.

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

## RE: Total figure not accurate?

Clng:<BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctclng.asp<BR>"For example, use CInt or CLng to force integer arithmetic in cases where currency, single-precision, or double-precision arithmetic normally would occur."<BR><BR>CDbl:<BR>http://msdn.microsoft.com/library/en-us/script56/html/vsfctcdbl.asp<BR><BR>Craig.<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
•