I am wandeering if someone can help me to modify the following code to do the following:
1. Ensure that the values in either textBoxmin.Text, textBoxhrs.Text or textBoxsec.Text) can ONLY be integers (if another character is entered, an error is thrown)
2. Ensure that only if AT LEAST ONE INTEGER is entered in either of the 3 text blocks, the operation can proceed (if there are no values entered, an error is thrown)
if ((textBoxhrs.Text != "") || (textBoxmin.Text != "") || (textBoxsec.Text != ""))
//If there is at least one value entered in any of the 3 boxes
try
{
hours = System.Convert.ToInt32(textBoxhrs.Text);
minutes = System.Convert.ToInt32(textBoxmin.Text);
seconds = System.Convert.ToInt32(textBoxsec.Text);
}
catch
{
MessageBox.Show("Only numbers allowed!!!");
//HOWEVER - if I type in one integer, the error is still thrown, when instead the program should proceed)

New Topic/Question
Reply




MultiQuote






|