Perhaps something like,
Int32 myInt = 0;
if ( System::Text::RegularExpressions::Regex::IsMatch(myTextBox->Text,
"^[-0-9]*.[.0-9].[0-9]*$") )
{
myInt = System::Convert::ToInt32 ( myTextBox->Text );
}
else
{
MessageBox::Show("Not a number");
}
This is an excerpt from another message board on the same topic.