Results 1 to 4 of 4

Thread: [RESOLVED] [2008] Validating input data

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134

    Resolved [RESOLVED] [2008] Validating input data

    how can I stop the input of the keyboard for a user

    I want that everytime the user press a key the program read what key was and only accept some keys that I want

  2. #2
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2008] Validating input data

    vb.net Code:
    1. Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As KeyEventArgs) Handles TextBox1.KeyDown
    2.     If Not e.KeyCode = Keys.A Then 'A is an accepted key
    3.         e.Handled = True
    4.     End If
    5. End Sub

    that should work

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Dec 2001
    Posts
    134

    Re: [2008] Validating input data

    It didn't work but I found a solution
    Code:
    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
            If Not e.KeyCode = Keys.A Then 'A is an accepted key        
                e.SuppressKeyPress = True
            End If
        End Sub

  4. #4
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [RESOLVED] [2008] Validating input data

    That was what I meant:P

    Glad you found it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width