convert varchar into float in classic asp

I want to convert varchar variable into float..
Is it possible in classic asp.
If yes can you give some example for me..

When i am inserting multiple records at a time, it is accepting only varchar datatypes..when i declare it as float it is not inserting..
so i want to convert it from varchar to float to make caluculations..

Who is Participating?
Big MontySenior Web Developer / CEO of Commented:
you can try using the CDbl() function:

num = "123.456"
num = CDbl( num )
lucky20Author Commented:
is that in sql or asp?
lucky20Author Commented:
oh sorry.. i got it..
i will try this
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

lucky20Author Commented:
can u give the sample u use it in real programming?

Big MontySenior Web Developer / CEO of Commented:
maybe if you show the code you're trying to get working, I can take a look and see if I can help you directly with that
lucky20Author Commented:
To be honest, I don't know how to use this in my program..

for i=1 to 5 
                    Set sql=Server.CreateObject("ADODB.Command")  
                    getquantity = request.form("quantity_"& i)
                    getitemid = request.form("itemid_"& i)
                    getcase=request.form("case_"& i)
                    if getitemid <> "" and getquantity <> ""and getcase <> "" then  
                    sql.commandtext="insert into items(itemid,quantity,case_i,inventory_taken)values(?,?,?,getdate())"
 sql.Parameters.Append sql.CreateParameter("@itemid", adInteger, adParamInput, , getitemid)
                    sql.Parameters.Append sql.CreateParameter("@quamntity", advarchar, adParamInput,15 , getquantity)
                    sql.Parameters.Append sql.CreateParameter("@case_i", adVarchar, adParamInput,13 , getcase) 
                    end if

Open in new window

Here quantity is declared as varchar in database.
(If i declare it as float,this insert statement is not declared it as varchar)
But i need quantity values to make caluculations..

So I want to convert it to varchar to float values
Big MontySenior Web Developer / CEO of Commented:
ok I thought you wanted the ASP equivalent, but it looks like you want the sql server equivalent. have a look at for a list of constants you can use. you want to use adSingle or adDouble:

sql.Parameters.Append sql.CreateParameter("@quamntity", adSingle, adParamInput,15 , getquantity)

also, it looks like you may have a typo in the parameter name (@quaMntity)
lucky20Author Commented:
ad single only takes single integer(4),
or if i use ad doublemit also takes only two digit numeric value(87).
Is there anything will accept 23.94(like float values).
lucky20Author Commented:
AdDouble will accept float values..I got it..

Sorry it was my mistake. I read desription of tinyint..
Thanks for information..
Big MontySenior Web Developer / CEO of Commented:
glad I could help :)

don't forget to close the question out!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.