validar textbox para que no quede vacio
Publicado por Alfredo (3 intervenciones) el 29/04/2008 08:13:22
cómo puedo validar un textbox para impedir que quede vacío????/, muchas gracias
Valora esta pregunta


0
Function valida() As Boolean
Dim Obj As Object
For Each Obj In Me.Controls
If Obj.Tag = "valida" Then
If Trim(Obj.Text) = "" Then
MsgBox "Campo por validar", vbInformation
Obj.SetFocus
valida = False
Exit For
Else
valida = True
End If
End If
Next
End Function
If Trim(Text1.Text) = "" Then
MsgBox "vacio"
End If
Private Sub Campo_requerido()
Dim T As Control
For Each T In Me.Controls
If TypeOf T Is TextBox Then
If Trim(T.Text) = "" Then
camporequerido.SetError(T, "Campo Requerido")
'Else
' MessageBox.Show("Dot Net Perls is awesome.")
End If
Else
' mesagebox aqui hay otro control diferente de textbox
End If
Next
End Sub
Private Function validar_campos() As Boolean
If Trim(TextBox1.Text) = "" Then
MsgBox "Ingrese el primer número"
validar_campos = False
ElseIf Trim(TextBox2.Text) = "" Then
MsgBox "Ingrese el segundo número"
validar_campos = False
Else
validar_campos = True
End If
End Function
if Text1.text = "" Then
MessageBox.Show("vacio")
End If
Me.txtCajaTexto.Clear()
If txtCajaTexto.Text.Length = 0 Then
MsgBox("Ingrese el texto a buscar", MsgBoxStyle.Critical, "Operacion no valida")
else
Me.XXXTableAdapter.FillByEJEMPLO(XXXDataSet.XXX, "%" & txtCajaTexto.Text & "%")
end if
Function EspacioBlanco(TextBox As Control, Mensaje As String) As Boolean
If TextBox.Text = "" Then
MsgBox (Mensaje), vbInformation
TextBox.SetFocus ' Te ubica la caja de texto no rellenado
EspacioBlanco = True
Exit Function
Else
EspacioBlanco = False
End If
End Function
If TextBox1 = Empty Then
TextBox1.SetFocus
Else
'resto del codigo a ejecutar
End if
Private Sub full_botton01_Click()
Dim RESPUESTA As Integer
If IsNull(texto01) Or texto01 = "" Then
RESPUESTA = MsgBox("Debe ingresar fecha del proceso (aaaammdd)", vbCritical)
texto01.SetFocus: Exit Sub
End If
End Sub
Private Sub T1_Change()
If T1.Value = "" Then
T2.Enabled = False
Else
T2.Enabled = True
End If
cb1.Enabled = False
End Sub
Private Sub T2_Change()
If T2.Value = "" Then
T3.Enabled = False
Else
T3.Enabled = True
End If
cb1.Enabled = False
End Sub
Private Sub T3_Change()
If T3.Value = "" Then
T4.Enabled = False
Else
T4.Enabled = True
End If
cb1.Enabled = False
End Sub
Private Sub T4_Change()
If T4.Value = "" Then
T5.Enabled = False
Else
T5.Enabled = True
End If
cb1.Enabled = False
End Sub
Private Sub t5_change()
If T5.Value = "" Then
T6.Enabled = False
Else
T6.Enabled = True
End If
cb1.Enabled = False
End Sub
Private Sub T6_Change()
If T6.Value = "" Then
T7.Enabled = False
Else
T7.Enabled = True
End If
cb1.Enabled = False
End Sub
Private Sub T7_Change()
If T7.Value = "" Then
cb1.Enabled = False
Else
cb1.Enabled = True
End If
End Sub
private function CHEQUEAR() as boolean
CHEQUEAR = FALSE
DIM BUCLE as INTEGER
FOR BUCLE =0 TO UBOUND(textbox)
if len(textbox(bucle).text) =0 then
msgbox"Operación Cancelada: No se incluye el valor para el campo " & label1(bucle).cation, vbcritical
exit function
end if
next bucle
CHEQUEAR = TRUE
end sub
private sub TXT_CLICK()
if chequear = true then
'Operación a ejecutar
end if
end sub
Private sub STAR()
DIM BUCLE as INTEGER
FOR BUCLE =0 TO UBOUND(textbox)
textbox(Bucle).text =0
NEXT Bucle
EN Sub
option explicit
dim SOLVER as variant
Private Sub text1_GotFocus(Index As Integer)
solver = text1(Index).Text
End Sub
Private Sub text1_LostFocus(Index As Integer)
If Len(text1(Index).Text) = 0 Then
text1(Index) = solver
End If
End Sub
If Len(TextBox1.value) = 0 Then
TextBox1.Value = 0
End If