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

String verses Integer for + operator

Status
Not open for further replies.

uva2000grad

Programmer
Jul 10, 2001
4
US
I've run into a typing problem in vbscript ( imagin that)
I've got some values in a DB that I need to sum. They are BOTH Number types in Oracle. I have a function called DescNumber that converts NULLS to 0 and any other numbers it performs a Cdbl() on the variable.
The expression:
DescNumber ( Value1) + DescNumber( Value2 ) return 10 if value1 = 1 and value2 = 0 ie STRING concatenation!
but if it's written
DescNumber( Value1 + Value2 ) it returns 1.

What am I missing???? Thanks ahead of time.
 
I tried that- I seems that CDBL(2300) returns 2,300. IS that considered a string?
 
this works oke with my version (6 SP4):

<%@ Language=VBScript %>
<%
function DescNumber(n)
if isnull(n) then
DescNumber = Cdbl(0)
else
DescNumber = Cdbl(n)
end if
end function

Response.Write DescNumber(1) + DescNumber(0) & &quot;<br>&quot;
Response.Write DescNumber(2300) + DescNumber(700)
%> br
Gerard
 
Hey Foxbox- are you useing IIS 5? I'm stuck with 4. Thanks.
 
Why dont u try to use Int function
int(DescNumber ( Value1)) + int(DescNumber( Value2 ))
________

George
 
I'd really like to use the CLNG() function because it doesn't seem to insert the &quot;,&quot;- but the values I am working with can be over 2,147,483,647 so I need to use CDBL().
 
>Hey Foxbox- are you useing IIS 5
Yep. And SQL Server 7, all under Win2K. br
Gerard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top