Textbox que permite sólo Letras en Vb.Net 05

Como en el ejemplo de solo números este código lo colocamos en el evento KeyPress de nuestras cajas de texto


If Char.IsLetter(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsSeparator(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
End If

y así tenemos solo texto en nuestras cajas de texto

nos vemos

3 Responses to Textbox que permite sólo Letras en Vb.Net 05

  1. kain_raziel says:

    Bueno mira según el código que pusiste me parece bien pero al momento de implementarlo me dice que requiere de un objeto y la vdd no se cual es el objeto si me pudieras ayudar te lo agradecería hasta luego.

  2. GeoAvila says:

    te comento acabo de probar el código y en realidad no aparece ningún error acá el ejemplo implementado.

        Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
            If Char.IsLetter(e.KeyChar) Then
                e.Handled = False
            ElseIf Char.IsControl(e.KeyChar) Then
                e.Handled = False
            ElseIf Char.IsSeparator(e.KeyChar) Then
                e.Handled = False
            Else
                e.Handled = True
            End If
        End Sub
    

    si el error persiste podrías intentar instalando el Service Pack 1 del VB2005

    nos vemos.

  3. joss says:

    hola, ya es viejo el post, pero bueno, si funciona, pero con el evento, keypress

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>