top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Allow backspace in keypress event

+2 votes
348 views

I want only 4 digit numbers and delete and backspace.

posted Aug 26, 2014 by Merry

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
 
Best answer
Private Sub TxtPStof_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtPStof.KeyPress 

    if e.KeyChar <> ControlChars.Back then
        e.Handled = Not (Char.IsDigit(e.KeyChar)  
    end if

End Sub 
answer Aug 27, 2014 by Asmita Agrawal
...