Pregunta

I have a text box in a loan calculator program and the maximum amount of months for user input needs to be set at 84, how do I set the text box to reject any number over 84?

¿Fue útil?

Solución

Use a NumericUpDown control instead of a Textbox if you only want the user to input a numeric value. You can then set the Maximum property to 84

Otros consejos

In the textbox's TextChanged even, add something like this -

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
         If Integer.Parse(TextBox1.Text) > 84 Then TextBox1.Text = "84"

End Sub

try it :

Private Sub Textbox1_OnValueChanged(sender As Object, e As EventArgs) Handles Textbox1.OnValueChanged
    If Val(Textbox1.Text) > 84 Then Textbox1.Text = "84"
End Sub
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top