Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/07/2008, 18:20
krokstyle
 
Fecha de Ingreso: julio-2008
Mensajes: 3
Antigüedad: 15 años, 10 meses
Puntos: 0
Validar Textbox Con Solo Letras Hecho Con Funcion

Hola...estoy trabajando con VB.NET 2005 y necesito validar un textbox en donde me permita ingresar solo letras, que al ingresar la primera letra despliegue un msgbox y limpie lo ingresado... Tengo esta funcion pero no me anda bien...
Solicito sugerencias...por favor...Gracias...




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


APLICACION DE LA FUNCION EN UN TEXTBOX....
_________________________________________



Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
Dim u As Boolean
valida(TextBox2.Text, u)
If u = True Then
MsgBox("INGRESE SOLO LETRAS", MsgBoxStyle.Information, "Información")
TextBox2.Clear()

End If
End Sub



Bye!