Saturday, 14 January 2012

Integer Textbox


Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        'allow only numbers, the Backspace key and the dot
        If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
        AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar <> "." Then
            'cancel keys
            e.Handled = True
        End If
    End Sub

No comments:

Post a Comment