Odd ball question----
Macro Wizard / Form >> TextField Limit to a number range?
I know how to limit a textfield to 2 digits and I know how to limit to numbers only.
But, is there a way to limit the typed range to say 0-12??
Thanks,
void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) )
{
e.Handled = true;
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
{
if (textBox1.Text == "0" || textBox1.Text == "1" || textBox1.Text == "3")
{
e.Handled = true;
}
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
{
int i = Convert.ToInt32(textBox1.Text);
if (i >=0 && i >= 12)
{
e.Handled = true;
}
}
}
textbox.MaxKength = 2;
Users browsing this forum: No registered users and 0 guests