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

How to convert string into number ...

Status
Not open for further replies.

msng

Programmer
Oct 14, 2003
27
US
how do I convert string to a number value. I have the database field value as 1 which is of the type string. I have to convert this value 1 into number datatype and add 1 to it.

Please let me know.

Thanks in advance for your help.
 
in cf if you have
<cfset charNum = "1"> <!--- string because it is in quotes --->
you can do math with any math operator
<cfset charNum = charNum+charNum>
<!--- this produces 2 --->
you can do string functions with it using the & symbol

<cfset charNum = charNum&charNum>
<!--- this will make "22" --->
<cfset charNum = charNum + 1>
<!--- this will give you 23 --->

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
oops sorry wasn't done yet

here is your proof

Code:
<cfoutput>
<cfset charNum = "1"> 
#charNum# *1*<br>
<cfset charNum = charNum+charNum>
#charNum# *2*<br>
<cfset charNum = charNum&charNum>
#charNum# *22*<br>
<cfset charNum = charNum + 1>
#charNum# *23*<br>
</cfoutput>

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top