I am currently trying to validate a textbox, so only letters (a-Z) can be entered, with the use of TryParseExact.
I have a code to check a time, although could someone demonstrate how this could be done with letters only.
My code is as follows:
private void textBox2_Validating(object sender, CancelEventArgs e)
{
DateTime dateEntered;
if (DateTime.TryParseExact(textBox2.Text, "HH:mm", System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out dateEntered))
{
}
else
{
MessageBox.Show("You need to enter valid 24 hour time");
}
}
with letters only? No numbers? No spaces or punctuation?