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!

differences between strings and numbers

Status
Not open for further replies.

611brain

Programmer
Feb 26, 2007
10
CA
I have script sample but i don't understand
here is my script:

<%
dtrfirstnum = “35”
intsecondnum = 40
strthirdnum = “50”
inttotal = strfirstnum * intsecondnum
Response.write inttotal
%>

what is different between "35" and 35.. for example:

intsecondnum is "40" and strthirdnum="56"
response.write intsecondnum * strthirdnum

and

intsecondnum is 40 and strthirdnum="56"

response.write intsecondnum * strthirdnum
OR

response.write intsecondnum + strthirdnum
________________________________________________________

can you please explain me what is differences between "" and without "". how does this caculation works? what is different between them?

thanks
 
All variables in VBScript are Variant.
Using math operator (like *) coerce the operands to numeric.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
hm... can you please explain me more detail with example

thanks

 
To be safe, always convert to the correct type and never use + for string concatenation: always use &
Code:
one = "12"
two = 23
intval = cint(one) + two ' will give 35
strval = one & cstr(two) ' will give 1223
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top