C
C# Learner
I am working n 1.1 btw so i'll have to validate it.
It might be better UI design to only allow the user to enter a valid value,
using a KeyPress event handler such as:
void textBox_KeyPress(object sender, KeyPressEventArgs e) {
e.Handled = !(Char.IsDigit(e.KeyChar) || e.KeyChar == '\b');
}
Also, you'll have to take into account that the user could enter a value
that will be higher than an Int32 can hold. You could get around this by
setting textBox.MaxLength to some value (specifically, a value less than
Int32.MaxValue.ToString().Length, which is 10).
If this isn't desirable, you'd have to just catch the exception in the next
statement and handle it.
I will look at using the convert service on the text box class though.
Int32.Parse(textBox.Text).