Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem adding decimal numbers 1

Status
Not open for further replies.

krappleby025

Programmer
Sep 6, 2001
347
NL
hi all can you help, I am using the following script to add decimal numbers but it is not working

<%
set query3 = con.execute(&quot;SELECT AmountCredit, AmountDebit FROM &quot; & TransactionTable & &quot; WHERE ScreenName = '&quot; & Session(&quot;Logedin&quot;) & &quot;'&quot;)
if not query3.eof then
Do until query3.eof
AmountCredit = query3(&quot;AmountCredit&quot;)
AmountDebit = query3(&quot;AmountDebit&quot;)
TotalCredit = cint(TotalCredit) + cint(AmountCredit)
TotalDebit = cint(TotalDebit) + cint(AmountDebit)
TotalComm = cint(TotalCredit) - cint(TotalDebit)
query3.movenext
loop
end if
%>
Now i want to display the total, by using the command =totalcomm

but it is not displaying it...

The page displays

0.50
0.05
0.05
total 0.00

any help would be appreciated, BY the way, i am using MYSQL and the field is set up as Decimal 6,2
thanks
 
How can these be decimal numbers if you are casting them to integer values(cInt) ?

Could you display the code where you are writing the output as well? --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
here is the entire code for that section

<%
set query3 = con.execute(&quot;SELECT AmountCredit, AmountDebit FROM &quot; & TransactionTable & &quot; WHERE ScreenName = '&quot; & Session(&quot;Logedin&quot;) & &quot;'&quot;)
if not query3.eof then
Do until query3.eof
AmountCredit = query3(&quot;AmountCredit&quot;)
AmountDebit = query3(&quot;AmountDebit&quot;)
TotalCredit = cint(TotalCredit) + cint(AmountCredit)
TotalDebit = cint(TotalDebit) + cint(AmountDebit)
TotalComm = TotalCredit - TotalDebitquery3.movenext
loop
end if
%>

<center>
<td width=&quot;50&quot; align=&quot;center&quot;><b><font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#FFCC00&quot;>$<% =TotalCredit %></font></b></td>
<td width=&quot;50&quot; align=&quot;center&quot;><b><font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#FFCC00&quot;>$<% =TotalDebit %></font></b></td>
</tr>

<tr>
<td width=&quot;100&quot; align=&quot;center&quot;></td>
</center>
<td align=&quot;center&quot;>
<p align=&quot;right&quot;><font color=&quot;#FFCC00&quot; size=&quot;2&quot; face=&quot;Arial&quot;><b>Grand
Total Owed</b></font></td>
<center>
<td width=&quot;100&quot; align=&quot;center&quot; colspan=&quot;2&quot; bgcolor=&quot;#C0C0C0&quot;><font face=&quot;Arial&quot; size=&quot;2&quot;><b>$<% =Totalcomm %></b></font></td>
</tr>
</table>
<p align=&quot;center&quot;>&nbsp;</p>

</center>

i have tried alsorts, but cannot get it to actually add the decimals, and display the total decimals,
have tried to do it without the cint but get this error message

Microsoft VBScript runtime error '800a000d'
Type mismatch

/TTL/logged/Commissions.asp, line 136

i am not a proffesional asp programmer, so my script isnt top notch, but it gets what i need done done, Any suggestions would be appreciated
 
ps. the query3.movenext is actually meant to be on the next line
 
Try this
Code:
TotalCredit = cdbl(TotalCredit) + cdbl(AmountCredit)
TotalDebit = cdbl(TotalDebit) + cdbl(AmountDebit)


Thanks,

Gabe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top