VISUAL BASIC 2008


CODIGO PARA ACEPTAR SOLO CARACTERES DE TIPO NUMERO





'CÓDIGO PARA QUE SOLO ACPTE DATOS DE TIPO NUMERO, EN LA CLAVE DE ALUMNO

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

If Char.IsNumber(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

Otro codigo solo para acpeptar caracteres de tipo numero


Dim numeros() As Char = {“1″, “2″, “3″, “4″, “5″, “6″, “7″, “8″, “9″, “0″}

Private Sub txtCuadro_KeyPress(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles txtCuadro.KeyPress

If Array.IndexOf(numeros, e.KeyChar) >= 0 Then
e.Handled = False
Else
e.Handled = True
End If




0 comentarios: