I have the following event handlers for a button and a text box:
private: System::Void button_Click(System::Object^ sender, System::EventArgs^ e)
{ function(0);
}
private: System::Void textBox_Validating(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e)
{ if(!CheckIfTextBoxNumeric(textBox))
e->Cancel = true;
}
bool CheckIfTextBoxNumeric(TextBox^ myTextBox1)
{ //checks text input only contains numbers
//returns true if so
}
void function(int select)
{ int result = 0;
//validate text is digit
try
{ result = Convert::ToInt32(insrtMnytxtBox->Text); ----- line A
}
catch(Exception^ myException)
{ cstmrInfolabel->Text = "Exception : ",myException->Message;
}
//rest of code
}
When program execution reaches line A in function, program does not pause for text input from user, that is, program does not allow user the chance to enter numbers. In C++ it would be the equivalent of cin >> result; How can I cause the program to pause so that the user has a chance to enter something.
private: System::Void button_Click(System::Object^ sender, System::EventArgs^ e)
{ function(0);
}
private: System::Void textBox_Validating(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e)
{ if(!CheckIfTextBoxNumeric(textBox))
e->Cancel = true;
}
bool CheckIfTextBoxNumeric(TextBox^ myTextBox1)
{ //checks text input only contains numbers
//returns true if so
}
void function(int select)
{ int result = 0;
//validate text is digit
try
{ result = Convert::ToInt32(insrtMnytxtBox->Text); ----- line A
}
catch(Exception^ myException)
{ cstmrInfolabel->Text = "Exception : ",myException->Message;
}
//rest of code
}
When program execution reaches line A in function, program does not pause for text input from user, that is, program does not allow user the chance to enter numbers. In C++ it would be the equivalent of cin >> result; How can I cause the program to pause so that the user has a chance to enter something.