Bloquear tecla no textbox no VB.NET

157 views
Skip to first unread message

Thyago

unread,
May 4, 2011, 8:45:58 AM5/4/11
to etecpg-2-se...@googlegroups.com
Private Sub bloquearTeclas(ByVal sender As System.Object, ByVal e As KeyPressEventArgs) Handles textbox.KeyPress, textbox2.KeyPress
        If (Asc(e.KeyChar) <> 8 And Asc(e.KeyChar) <> 9 And Asc(e.KeyChar) <> 13 And Asc(e.KeyChar) <> 44 And Asc(e.KeyChar) <> 46 And Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57) Then
            e.Handled = True
        Else
            If Asc(e.KeyChar) = 46 Then
                e.KeyChar = Chr(44)
            End If
        End If
    End Sub

esse é o código para bloquear tecla em textbox.

Marcos Costa

unread,
May 7, 2011, 7:28:24 PM5/7/11
to etecpg 2ª semestre 2010
Outra dica:
Caso seja uma textbox de valores inteiros, remova a seguinte parte do
if: "And Asc(e.KeyChar) <> 44 And Asc(e.KeyChar) <> 46"
Reply all
Reply to author
Forward
0 new messages