Ver Mensaje Individual
  #7 (permalink)  
Antiguo 02/07/2008, 18:08
krokstyle
 
Fecha de Ingreso: julio-2008
Mensajes: 3
Antigüedad: 15 años, 10 meses
Puntos: 0
Respuesta: Validacion De Textbox Y Otros.

Hola...
aqui tengo una funcion que valida solo numeros...

Function valida(ByVal letra As String, ByRef v As Boolean)

Dim n As Integer
Dim x As Integer
Dim a As Integer
Dim c As Integer
n = Len(letra)
For x = 1 To n + 1
For a = 0 To 9
If Strings.Mid(letra, x, 1) = CStr(a) Then
c = c + 1
End If
Next
Next
If c = n Then
v = True
End If
Return (v)

End Function



Y para luego aplicarla....
es así...

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
Dim u As Boolean
valida(TextBox1.Text, u)
If u = False Then
MsgBox("INGRESE SOLO NÚMEROS", MsgBoxStyle.Information, "Información")
TextBox1.Clear()

End If
End Sub



esta validacion funciona con el VB.net 2005 no he probado con otro...