Re: test if a string is a valid 'number'?
- From: "Ashot Geodakov" <a_geodakov@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 30 May 2007 13:43:16 -0700
"Doug Harrison [MVP]" <dsh@xxxxxxxx> wrote in message
news:88or53ddfip8v2bcdud4jqh8m4lge0q1lg@xxxxxxxxxx
On Wed, 30 May 2007 13:28:16 -0700, "Ashot Geodakov"
<a_geodakov@xxxxxxxxxxxxxxxxxx> wrote:
#include <windows.h>
typedef long ( *ISNUMERIC )( VARIANT* );
BOOL IsNumeric( LPTSTR szString )
{
HINSTANCE hinstLib;
ISNUMERIC ProcAdd;
hinstLib = LoadLibrary( TEXT( "C:\\Program Files\\Common
Files\\Microsoft Shared\\VBA\\VBA6\\vbe6.dll" ) );
if( hinstLib != NULL )
{
long lNumeric = 0;
ProcAdd = (ISNUMERIC)GetProcAddress( hinstLib, "rtcIsNumeric" );
if( NULL != ProcAdd )
{
VARIANT vtExpression;
vtExpression.vt = VT_BSTR;
vtExpression.bstrVal = SysAllocString( szString );
__asm
{
lea eax, [vtExpression]
push eax
call (ProcAdd)
mov lNumeric, eax
}
SysFreeString( vtExpression.bstrVal );
}
FreeLibrary( hinstLib );
return ( lNumeric != 0 );
}
else return FALSE;
}
void main( void )
{
BOOL bNumeric = IsNumeric( TEXT( "1245789.00" ) );
bNumeric = IsNumeric( TEXT( "sdf1245789.00" ) );
bNumeric = IsNumeric( TEXT( "+234.43E-24" ) );
bNumeric = IsNumeric( TEXT( "12,234,345.00" ) );
bNumeric = IsNumeric( TEXT( "sdf1245789.00" ) );
}
Shirley you're just kiddin' around.
Why? It works...
.
- Follow-Ups:
- Re: test if a string is a valid 'number'?
- From: Joseph M . Newcomer
- Re: test if a string is a valid 'number'?
- From: AliR \(VC++ MVP\)
- Re: test if a string is a valid 'number'?
- References:
- Re: test if a string is a valid 'number'?
- From: Ashot Geodakov
- Re: test if a string is a valid 'number'?
- From: Doug Harrison [MVP]
- Re: test if a string is a valid 'number'?
- Prev by Date: Re: test if a string is a valid 'number'?
- Next by Date: Re: test if a string is a valid 'number'?
- Previous by thread: Re: test if a string is a valid 'number'?
- Next by thread: Re: test if a string is a valid 'number'?
- Index(es):
Relevant Pages
|