Vb Keypress

This keypress will work if you want the textbox to accept numeric data only

For VB.net

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

If Not IsNumeric(e.KeyChar) Then
e.KeyChar = Chr(0)
End If
End Sub

For VB 5 & 6

on keypress event

Private Sub txtEndtNo_KeyPress(KeyAscii As Integer)
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 13 And KeyAscii <> 8 Then KeyAscii = 0
End Sub

Explore posts in the same categories: Programming VB

Tags: , ,

You can comment below, or link to this permanent URL from your own site.

Comment: