Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Variable numeric or character
Message
 
To
10/01/2014 02:59:42
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01591614
Message ID:
01591624
Views:
59
>>Does anyone know how I test if a variable is a number (value) or a character?
>>
>>thanks
>>k
>
>Try this
>
>
>
>? Type_IsNumeric(m.myVar)
>
>? Type_IsChar(m.myVar)
>
>
>#define T_NUMERIC_LIST	T_NUMERIC, T_DOUBLE, 'I', T_CURRENCY
>*_______________________________________________________________________________
>
>function Type_IsNumeric(n)
>	
>	return 		inlist(vartype(m.n), T_NUMERIC_LIST)
>
>endfunc
>*_______________________________________________________________________________
>
>function Type_IsChar(s)
>
>	return 	inlist(vartype(m.s), T_CHARACTER, T_MEMO, 'V', 'Q', 'W') 
>
>endfunc
>*_______________________________________________________________________________
>
Beware, do not use TYPE(). It was added for speed but makes little difference and is known for returning the wrong result at times. I have seen this myself.
Beer is proof that God loves man, and wants him to be happy. - Benjamin Franklin
John J. Henn
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform