Only allowing up to three digit numeric characters in a text box
Is there a way to only allow a user to input a maximum number of characters into a text box? I want the user to input a mark/grade and only be able to input 0 - 100. Below I have code that monitors the keystroke and only allows for numbers to be input, but I want to find a way to only allow the user to input a number with a minimum value of 0 and a maximum of 100. private void TxtMark4_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar < '0' || e.KeyChar > '9' || e.KeyChar == ' ') { e.Handled = true; } else { e.Handled = false; } } or I could use the following: if (e.KeyChar >= 48 &&