Yikes, that's a lot of work. I thought my example was too much :o)
#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" ) );
}
"WJ" <WJ@discussions.microsoft.com> wrote in message
news:B191F239-907C-4468-B8D6-B794460DF3C5@microsoft.com...
Hi,
I have a string that I want convert to a number. Before doing that, I
need
to test if the string represents a valid 'number'.
I remember there is a function to do that, but I can't find it.
(I am NOT using .net, I am using MFC)
Thanks.