vendredi 26 février 2016

Autocorrecting textbox input (vb.net code)

I cant get the following vb.net code too work. What Im trying to achive is to limit the numbers used between and inclusive of 3 and 6. if a user dose enter a value less than 3 that the textbox corrects the value to 3 and if a user enters a value greater than 6 the textbox value is changed to 6...

Select Case e.KeyChar
    Case "3", "4", "5", "6", vbBack
        e.Handled = False
    Case Else
        e.Handled = True
        If TextBox27.Text <= 2 Then
            MessageBox.Show("Minimum of 3 loads permissible", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information)
            TextBox27.Text = "3"
            TextBox27.Focus()
        ElseIf TextBox27.Text >= 7 Then
            'Shows error message...
            MessageBox.Show("Maximum of 6 loads permissible", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information)
            TextBox27.Text = "6"
            TextBox27.Focus()
        End If

End Select

Aucun commentaire:

Enregistrer un commentaire