Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it numeric

Status
Not open for further replies.

nicktherod

Programmer
Nov 10, 2000
19
CA
I have an edit box and I want only numbers coming in. In C there is the IsNumeric(), is there anything like that for VC++.

Thanks
 
Since C++ is a supeset of C, and Visual C++ is a ANSI compliance compiler, you'd think that the IsNumeric() would work in Visual C++.
 
One option is to use the class wizard and assign a member variable to the edit control and assign the data type by selecting the appropriate data type (i.e. int, uint, long, double, float, etc.) This will allow only numeric values. You can also assign a valid range for the edit box.

HTH,
jc
 
If you create a derived class from CEdit and overwrite the
fuction OnChar() ( WM_CHAR ) than you can prevent alpha-characters coming in to the control:

void CYourClass::OnChar(............)
{
if ( nChar < 48 || nChar > 57 )
{
MessageBeep( ( WORD ) ) - 1 );
return;
}

CEdit::OnChar(...........)
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top