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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sum two variables

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
Hello,

I am trying to sum 2 variables but does not seem to work,

Here is what I have tried
Code:
<%response.Write(rsGuestbook("crqty1")*rsGuestbook("UnitPrice1"))%>

and
<% Dim
Num1=rsGuestbook("crqty1")
Num2=rsGuestbook("UnitPrice1")
Response.write(Num1*Num2)
%>
 
try:

Code:
<%response.Write(cstr(rsGuestbook("crqty1")*rsGuestbook("UnitPrice1")))%>

and

Code:
Response.write( cstr(Num1*Num2) )
 
the asterisk is a multiply, are you trying to sum (i.e. add) them or multiply them?

Code:
Num1=cint(rsGuestbook("crqty1"))
Num2=cint(rsGuestbook("UnitPrice1"))
Response.write Num1*Num2 ' to multiply
Response.write Num1+Num2 ' to sum


--------

GOOGLE is a great resource to find answers to questions like "how do i..."


--------
 
I prefer to convert to "Double" instead "integer".
Maybe in this case Cint() will work, but keep in mind that there is a value range vor Cint: -32,768 to 32,767 .

The range for CDbl is
-1.79769313486232E308 to -4.94065645841247E-324 for negative values and 4.94065645841247E-324 to 1.79769313486232E308 for positive values.


Code:
<% 
Num1=Cdbl( rsGuestbook("crqty1"))
Num2=CDbl( rsGuestbook("UnitPrice1"))
Response.write(Num1*Num2)
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top