i need one example keypress event Program in VB.Net
-
///6.0 If KeyAscii = 8 Then Exit Sub End If If KeyAscii = 46 Then If InStr(txtRate.Text, Chr(46)) = 0 Then Exit Sub Else KeyAscii = 0 End If End If If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 0 End If ///.Net 2005 If Asc(e.KeyChar) = 8 Then Exit Sub End If If Asc(e.KeyChar) = 46 Then If InStr(txtRate.Text, Chr(46)) = 0 Then Exit Sub Else e.Handled = True End If End If If Not IsNumeric(e.KeyChar) Then e.Handled = True End If End Sub //// this is for trapping only numbersand 1 decimal point in a textbox on the keypress event. hope it helps Love makes the world go round
-
All you have to do is handle the KeyDown event of the TextBox. I have no idea what you want to do with the Ascii value, so...
Private Sub TextBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
' The keycode is in e.Keycode.
Console.WriteLine("KeyCode value: " & e.KeyCode )
End SubDave Kreskowiak Microsoft MVP - Visual Basic