<Best Dr. McCoy Voice>It's a joke Jim</Best Dr. McCoy Voice>
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
See below...
On Wed, 30 May 2007 13:28:16 -0700, "Ashot Geodakov"
<a_geodakov@nospam.hotmail.com>
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
}
****
This is a weird way to write
INumeric = ProcAdd(&vtExpression);
Why revert to assembly code to do something that is already available in C
without any
effort at all?
****
SysFreeString( vtExpression.bstrVal );
}
FreeLibrary( hinstLib );
*****
Given the complexity and horrendous inefficiency of this solution, why is
it even a
candidate for consideration compared to writing a rather straightforward
FSM in C?
*****
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.
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm