Ver Mensaje Individual
  #5 (permalink)  
Antiguo 28/07/2011, 15:25
facufangio
 
Fecha de Ingreso: junio-2011
Mensajes: 7
Antigüedad: 12 años, 10 meses
Puntos: 1
Respuesta: Como hacer para validar un textbox?

MUCHAS GRACIAS JONATHAN B POR EL APORTE......Pero quiero comentarle a los 2 que me ha surguido un error al poner 2 textbox uno seguido del otro y darle enter o tab cuando ambos estan vacios....se me queda trabado con el msgbox....acá coloco el codigo que use....necesito si me pueden dar una mano....desde ya Gracias
Código vb:
Ver original
  1. Private Sub Text1_KeyPress(KeyAscii As Integer)
  2.         If KeyAscii = 13 Then SendKeys "{TAB}"
  3.     End Sub
  4.      
  5.     Private Sub Text1_LostFocus()
  6.         If Trim(Text1.Text) = Empty Then
  7.             MsgBox "No puede estar en blanco!", vbInformation
  8.             Text1.SetFocus
  9.         End If
  10.     End Sub
  11.     Private Sub Text2_KeyPress(KeyAscii As Integer)
  12.         If KeyAscii = 13 Then SendKeys "{TAB}"
  13.     End Sub
  14.      
  15.     Private Sub Text2_LostFocus()
  16.         If Trim(Text2.Text) = Empty Then
  17.             MsgBox "No puede estar en blanco!", vbInformation
  18.             Text2.SetFocus
  19.         End If
  20.     End Sub


y este es otro codigo que tambien use

Código vb:
Ver original
  1. Private Sub Text1_KeyPress(KeyAscii As Integer)
  2. If KeyAscii = 13 Then
  3. Text2.SetFocus
  4. Else
  5. KeyAscii = verificar_tecla(KeyAscii)
  6. End If
  7. End Sub
  8. Private Sub Text1_LostFocus()
  9. If Trim(Text1.Text) = Empty Then
  10. MsgBox "No puede estar en blanco!", vbInformation, "Control Stock"
  11. Text1.SetFocus
  12. End If
  13. End Sub
  14. Private Sub Text2_KeyPress(KeyAscii As Integer)
  15. If KeyAscii = 13 Then
  16. Text3.SetFocus
  17. Else
  18. KeyAscii = verificar_tecla(KeyAscii)
  19. End If
  20. End Sub
  21. Private Sub Text2_LostFocus()
  22. If Trim(Text2.Text) = Empty Then
  23. MsgBox "No puede estar en blanco!", vbInformation, "Control Stock"
  24. Text2.SetFocus
  25. End If
  26. End Sub

Última edición por facufangio; 28/07/2011 a las 15:32