Print Page | Close Window

adding up fields in asp

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: General Discussion
Forum Description: General discussion and chat on any topic.
URL: https://forums.webwiz.net/forum_posts.asp?TID=15011
Printed Date: 31 March 2026 at 6:33pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: adding up fields in asp
Posted By: t4p67b96
Subject: adding up fields in asp
Date Posted: 10 May 2005 at 12:22pm
I have a 4th asp page that is suppose to add specified fields from 3 other forms. When I test the page it just adds them like a string and not totaling them.  Below is how I have it now. I open all 3 connections (rst, rst2, rst3) Fields are named the same in each database table.
 
accidents = rst("Accidents") + rst2("Accidents") + rst3("Accidents")
ogpriorityoh = rst("OG Priority OH") + rst2("OG Priority OH") + rst3("OG Priority OH")
 
Then somewhere in the table I call for the total using for example
<%=ogpriorityoh%>.  So in the other 3 forms if I enter 3, 4, 5, I get 345 not 12.
 
thanks
 
t4p67b96
Confused



Replies:
Posted By: dpyers
Date Posted: 10 May 2005 at 12:51pm
Try
accidents = (Cint(rst("Accidents")) + Cint(rst2("Accidents")) + Cint(rst3("Accidents")))


-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: t4p67b96
Date Posted: 10 May 2005 at 2:03pm
Thank you.  That worked
 
 
 
Smile
t4p67b96
 


Posted By: dpyers
Date Posted: 10 May 2005 at 3:07pm
Not that the Convert to Integer Number instruction (Cint) only works with numbers up to 32K.
If you expect higher numbers, use the Convert to Long Number instruction (Clng). Uses more resources to run than Cint.


-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net