How do I verify a string is a numerical value?

Re: Check for numerical values by Eric

Eric
Wed Feb 04 08:16:07 CST 2004

Hello, Roger!
You wrote on Wed, 4 Feb 2004 08:55:24 -0500:

R> How do I verify a string is a numerical value?

?IsStringNumeric("123456")
?IsStringNumeric("123456A")
FUNCTION IsStringNumeric(tcString AS String)
RETURN LEN(CHRTRAN(tcString, CHRTRAN(tcString, "0123456789",""),"")) =
LEN(tcString)
ENDFUNC

--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



RE: Check for numerical values by anonymous

anonymous
Wed Feb 04 09:11:11 CST 2004

ISDIGIT(<string value>)

Determines whether the leftmost character of the specified character expression is a digit (0 through 9).

Re: Check for numerical values by Roger

Roger
Wed Feb 04 09:20:10 CST 2004

Thanks guys,

someone also told me I can use TYPE()... is this true?


"Eric den Doop" <ericdendoop@xspamblockxfoxite.com> wrote in message
news:e$28vly6DHA.2952@TK2MSFTNGP09.phx.gbl...
> Hello, Roger!
> You wrote on Wed, 4 Feb 2004 08:55:24 -0500:
>
> R> How do I verify a string is a numerical value?
>
> ?IsStringNumeric("123456")
> ?IsStringNumeric("123456A")
> FUNCTION IsStringNumeric(tcString AS String)
> RETURN LEN(CHRTRAN(tcString, CHRTRAN(tcString, "0123456789",""),"")) =
> LEN(tcString)
> ENDFUNC
>
> --
> Eric den Doop
> www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8
>
>



Re: Check for numerical values by Rick

Rick
Wed Feb 04 10:12:14 CST 2004

Roger,
No, at least not directly. You might be able to use it in a function =
that's got other code. Can you post some code that "someone" suggested?

Eric's code looks good as long as you only want to consider positive =
integers.=20

Rick

"Roger" <someone@microsoft.com> wrote in message =
news:eGyPAJz6DHA.2996@tk2msftngp13.phx.gbl...
> Thanks guys,
>=20
> someone also told me I can use TYPE()... is this true?
>=20
>=20
> "Eric den Doop" <ericdendoop@xspamblockxfoxite.com> wrote in message
> news:e$28vly6DHA.2952@TK2MSFTNGP09.phx.gbl...
> > Hello, Roger!
> > You wrote on Wed, 4 Feb 2004 08:55:24 -0500:
> >
> > R> How do I verify a string is a numerical value?
> >
> > ?IsStringNumeric("123456")
> > ?IsStringNumeric("123456A")
> > FUNCTION IsStringNumeric(tcString AS String)
> > RETURN LEN(CHRTRAN(tcString, CHRTRAN(tcString, =
"0123456789",""),"")) =3D
> > LEN(tcString)
> > ENDFUNC
> >
> > --=20
> > Eric den Doop
> > www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By =
VFP8
> >
> >
>=20
>

Re: Check for numerical values by Dan

Dan
Wed Feb 04 15:33:00 CST 2004

Val(theString) will return 0 if it isn't a legit number.

Dan

Roger wrote:
> How do I verify a string is a numerical value?



Re: Check for numerical values by Rick

Rick
Wed Feb 04 16:02:26 CST 2004

Dan,
Unless the string happens to be "00000000000" ! :-)

Rick

"Dan Freeman" <spam@microsoft.com> wrote in message =
news:%2324vUZ26DHA.2924@tk2msftngp13.phx.gbl...
> Val(theString) will return 0 if it isn't a legit number.
>=20
> Dan
>=20
> Roger wrote:
> > How do I verify a string is a numerical value?
>=20
>

Re: Check for numerical values by Rush

Rush
Wed Feb 04 16:34:48 CST 2004

VAL("23skidoo") returns 23.00.

- Rush


"Dan Freeman" <spam@microsoft.com> wrote in message
news:%2324vUZ26DHA.2924@tk2msftngp13.phx.gbl...
> Val(theString) will return 0 if it isn't a legit number.
>
> Dan
>
> Roger wrote:
> > How do I verify a string is a numerical value?
>
>



Re: Check for numerical values by Dan

Dan
Wed Feb 04 17:14:45 CST 2004

But if Transform(Val(TheString)) # TheString, you know you've got some
non-digits. <s>

Dan


Rush Strong wrote:
> VAL("23skidoo") returns 23.00.
>
> - Rush
>
>
> "Dan Freeman" <spam@microsoft.com> wrote in message
> news:%2324vUZ26DHA.2924@tk2msftngp13.phx.gbl...
>> Val(theString) will return 0 if it isn't a legit number.
>>
>> Dan
>>
>> Roger wrote:
>>> How do I verify a string is a numerical value?