i am using this codes to separate masked textbox values then put a validation where hour can only contain 0 to 23 while minute is 0 to 59. But still this doesn't work.
string text = maskedTextBox1.Text;
string[] parts = text.Split(':');
try
{
var hour = Convert.ToInt32(parts[0]);
var minute = Convert.ToInt32(parts[1]);
if (hour > 23 || minute >59)
SendKeys.Send("{BACKSPACE}");
else
if ((maskedTextBox1.Text.Length == 2) && (string.IsNullOrEmpty(maskedTextBox1.Text)))
maskedTextBox1.Focus();
}
catch (Exception ex)
{
}
Help please :)