Connecting Tech Pros Worldwide Forums | Help | Site Map

How to convert string to float?

Jason Chan
Guest
 
Posts: n/a
#1: Jul 19 '05
i want to covert a querystring to float number in asp.
what function should i use?

i know cint() can convert string to int
but how about float?



Martin CLAVREUIL
Guest
 
Posts: n/a
#2: Jul 19 '05

re: How to convert string to float?


hi,

usually you can use the round function.
As asp deals with the variant type, something tlike that should work

'querystring : ?id=1&value=10.874
id=request.querystring("id")
v=request.querystring("value")
v=round(v,3)


"Jason Chan" <no@email.com> a 嶰rit dans le message de
news:OZlikrpcDHA.856@tk2msftngp13.phx.gbl...[color=blue]
> i want to covert a querystring to float number in asp.
> what function should i use?
>
> i know cint() can convert string to int
> but how about float?
>
>[/color]


Alan
Guest
 
Posts: n/a
#3: Jul 19 '05

re: How to convert string to float?


CDbl() or CSng() will do the trick. Use IsNumeric() to make sure it's
numeric first.

Alan

"Jason Chan" <no@email.com> wrote in message
news:OZlikrpcDHA.856@tk2msftngp13.phx.gbl...[color=blue]
> i want to covert a querystring to float number in asp.
> what function should i use?
>
> i know cint() can convert string to int
> but how about float?
>
>[/color]


Jason Chan
Guest
 
Posts: n/a
#4: Jul 19 '05

re: How to convert string to float?


I got it, thanks~
"Martin CLAVREUIL" <martin.clavreuil@wanadoo.fr> 在郵件 news:e9XhoAqcDHA.1884@TK2MSFTNGP10.phx.gbl 中撰寫...[color=blue]
> hi,
>
> usually you can use the round function.
> As asp deals with the variant type, something tlike that should work
>
> 'querystring : ?id=1&value=10.874
> id=request.querystring("id")
> v=request.querystring("value")
> v=round(v,3)
>
>
> "Jason Chan" <no@email.com> a 嶰rit dans le message de
> news:OZlikrpcDHA.856@tk2msftngp13.phx.gbl...[color=green]
> > i want to covert a querystring to float number in asp.
> > what function should i use?
> >
> > i know cint() can convert string to int
> > but how about float?
> >
> >[/color]
>
>[/color]


Jason Chan
Guest
 
Posts: n/a
#5: Jul 19 '05

re: How to convert string to float?


Thanks for answering.
"Alan" <XalanX.XhowardX@XparadiseX.XnetX.XnzX> 在郵件 news:ep0OJhrcDHA.2672@tk2msftngp13.phx.gbl 中撰寫...[color=blue]
> CDbl() or CSng() will do the trick. Use IsNumeric() to make sure it's
> numeric first.
>
> Alan
>
> "Jason Chan" <no@email.com> wrote in message
> news:OZlikrpcDHA.856@tk2msftngp13.phx.gbl...[color=green]
> > i want to covert a querystring to float number in asp.
> > what function should i use?
> >
> > i know cint() can convert string to int
> > but how about float?
> >
> >[/color]
>
>[/color]


Closed Thread