i have a 1 textbox namely txtplate. I want the textbox that can input only Plate number. (example WXY 123 (with space and the 3 letters are in uppercase)

These methods are the easiest.

The alternate way would be to capture each character inserted into the textbox, check it, then submit it.

You would have to set the size limit of the textbox also.

thank you sir but is there any other solutions? beside your suggestions?

What is it that you find unacceptable about the solutions proposed thus far?

First in your textbox Properties

CharacterCasing: Upper
MaxLength: 7

In your textbox Keypress event:

Private Sub NumberOnly(ByVal e As System.Windows.Forms.KeyPressEventArgs)
        If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
            e.Handled = True
        End If
        If Asc(e.KeyChar) = 8 Then
            e.Handled = False
        End If
    End Sub

    Private Sub LetterOnly(ByVal e As System.Windows.Forms.KeyPressEventArgs)
        If Asc(e.KeyChar) < 65 Or Asc(e.KeyChar) > 90 And Asc(e.KeyChar) < 97 And Asc(e.KeyChar) > 122 Then
            If (Asc(e.KeyChar) <> 32) Then
                e.Handled = True
            End If
        End If
        If Asc(e.KeyChar) = 8 Then
            e.Handled = False
        End If
    End Sub
    Private Sub killchar(ByVal e As System.Windows.Forms.KeyPressEventArgs)
        If Asc(e.KeyChar) < 97 Or Asc(e.KeyChar) > 90 And Asc(e.KeyChar) < 127 And Asc(e.KeyChar) > 122 Then
            If (Asc(e.KeyChar) <> 32) Then
                e.Handled = True
            End If
        End If
        If Asc(e.KeyChar) = 8 Then
            e.Handled = False
        End If
    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If TextBox1.Text.Length >= 0 And TextBox1.Text.Length < 3 Then
            Call LetterOnly(e)
            Call killchar(e)
        ElseIf TextBox1.Text.Length >= 3 Then
            Call NumberOnly(e)
            If Asc(e.KeyChar) = 32 Then
                e.Handled = False
            End If
        End If
    End Sub
Comments
Looks like you just copy and pasted a (incorrect) solution someone had given you, without any thought or testing. It's very buggy.
kljkljkljklj

First in your textbox Properties

CharacterCasing: Upper
MaxLength: 7

In your textbox Keypress event:

So what happens if the user moves the caret to some position other than the end of the text? And why are you allowing spaces everywhere?

can you please tell me sir where can i put the

Private Sub killchar(ByVal e As System.Windows.Forms.KeyPressEventArgs)
Private Sub LetterOnly(ByVal e As System.Windows.Forms.KeyPressEventArgs)
Private Sub NumberOnly(ByVal e As System.Windows.Forms.KeyPressEventArgs

im a newbie in vb.net :D thank you

can you please tell me sir where can i put the

Private Sub killchar(ByVal e As System.Windows.Forms.KeyPressEventArgs)
Private Sub LetterOnly(ByVal e As System.Windows.Forms.KeyPressEventArgs)
Private Sub NumberOnly(ByVal e As System.Windows.Forms.KeyPressEventArgs

im a newbie in vb.net :D thank you

I wouldn't put it anywhere if I were you; the code's incredibly buggy.

This article has been dead for over six months. Start a new discussion instead.