Visual Basic - porfavor validacion de caja de texto

Life is soft - evento anual de software empresarial
 
Vista:

porfavor validacion de caja de texto

Publicado por alberto (8 intervenciones) el 26/07/2005 02:13:30
que tal todos
necesito hacer una validacion de una caja de texto para que no deje meter otro numero mayor a 100 si puede meter el 100 pero un 200 o 150 o 120 no puede solo de 100 para abajo.
tengo el siguiente codigo que me funciona para que no deje meter mas de 4 caracteres pero la validacion de 100 no me sale.

Private Sub porcenobj1_Validate(Cancel As Boolean)
With Me.porcenobj1
If Not Len(.Text) <= 3 Or Not IsNumeric(.Text) Then
MsgBox "escriba solo el numero del porcentage igual o menor a 100"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
Cancel = True
End If
End With
End Sub

alomejor es algo sencillo pero no mas no le hayo
gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 14
Ha aumentado 1 puesto en Visual Basic (en relación al último mes)
Gráfica de Visual Basic

RE:porfavor validacion de caja de texto

Publicado por SuNcO (599 intervenciones) el 26/07/2005 04:27:26
Checa haber que te parece esto un poco mas avanzadito

Pon un TextBox llamado Text1 e intenta meter numeros y mas de 3 numeros
La linea que indica cuantos numeros se permiten es esta :

' ------------- If Validar(Text1, 3) = False Then

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Const GWL_STYLE = (-16)
Const ES_NUMBER = &H2000&

Public Sub SetNumber(NumberText As Object, Flag As Boolean)
Dim curstyle As Long, newstyle As Long

curstyle = GetWindowLong(NumberText.hwnd, GWL_STYLE)

If Flag Then
curstyle = curstyle Or ES_NUMBER
Else
curstyle = curstyle And (Not ES_NUMBER)
End If

newstyle = SetWindowLong(NumberText.hwnd, GWL_STYLE, curstyle)

NumberText.Refresh
End Sub

Private Function Validar(Objeto As Object, Cuantos As Integer) As Boolean
If Len(Objeto.Text) < Cuantos Then
Validar = True
Else
Validar = False
End If
End Function

Private Sub Form_Load()
SetNumber Text1, True
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then
Exit Sub
End If
If Validar(Text1, 3) = False Then
KeyAscii = 0
End If
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:porfavor validacion de caja de texto

Publicado por carlos (101 intervenciones) el 26/07/2005 06:25:34
prueba lo sgte, no se si es lo que buscas, pero con validar que el VAL(TEXT) sea menor o igual a 100 te puede servir

Private Sub Text1_Change()
On Error GoTo ControlError

If Len(Text1) < 3 Then
GoTo ControlError
Else
If Val(Text1) > 100 Then
MsgBox "la cantidad ingresda es superor a 100, ingrese una cantidad menor"
Else
MsgBox Text1
End If
End If
ControlError:
Exit Sub
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:porfavor validacion de caja de texto

Publicado por alberto (8 intervenciones) el 26/07/2005 19:14:31
ey gracias a los 2 es justo lo que necesitaba gracias
cuando queiran aqui estamos gracias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar