Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

VALIDAR TEXTBOX PARA LLENAR LISTBOX

publicado

Buenas tardes; estimada comunidad, agradezco me ayuden con este caso.

Tengo una serie de textbox que cargan un listbox; los tengo condicionados para que, al dar clic en el boton de carga, me muestre un error si hay algo vacío; el problema es que la informacion se cargue al listbos solo cuando los 5 datos esten completos, pero lo que escribi sigue derecho y graba sin importar si todos estan completos.

 

Private Sub CommandButton14_Click()
'cargar informacion ref bancaria a listbox

    'validar que los campos esten completos
    If TextBox34 = Empty Then
        MsgBox "FALTA NOMBRE DE BENEFICIARIO", vbCritical
        TextBox34.SetFocus
    ElseIf TextBox35 = Empty Then
        MsgBox "FALTA NIT DE BENEFICIARIO", vbCritical
        TextBox35.SetFocus
    ElseIf ComboBox1.Value = Empty Then
        MsgBox "FALTA ENTIDAD BANCARIA", vbCritical
        ComboBox1.SetFocus
    ElseIf ComboBox2.Value = Empty Then
        MsgBox "FALTA TIPO DE CUENTA", vbCritical
        ComboBox2.SetFocus
    ElseIf TextBox33.Value = Empty Then
        MsgBox "NÚMERO DE CUENTA", vbCritical
        TextBox33.SetFocus
    End If

    'llenar listbox
        ListBox3.AddItem TextBox34.Value
        ListBox3.List(ListBox3.ListCount - 1, 1) = TextBox35.Value
        ListBox3.List(ListBox3.ListCount - 1, 2) = ComboBox1.Value
        ListBox3.List(ListBox3.ListCount - 1, 3) = ComboBox2.Value
        ListBox3.List(ListBox3.ListCount - 1, 4) = TextBox33.Value
        
End Sub

Featured Replies

publicado

Buenas, Una forma de tantas es poner un exit sub

If TextBox34 = Empty Then
        MsgBox "FALTA NOMBRE DE BENEFICIARIO", vbCritical
        TextBox34.SetFocus
        Exit Sub
.......

saludos

 

publicado
  • Autor

excelente solucion! Solo habia probado con la primera variable, pero al ponerselo a las demás funcionó perfecto.

Mil gracias

Tema cerrado

publicado

Te paso una mejor opcion : meter el el condicional el llenado de la lista

Private Sub CommandButton14_Click()
    'validar que los campos esten completos
    If TextBox34 = Empty Then
        MsgBox "FALTA NOMBRE DE BENEFICIARIO", vbCritical
        TextBox34.SetFocus
    ElseIf TextBox35 = Empty Then
        MsgBox "FALTA NIT DE BENEFICIARIO", vbCritical
        TextBox35.SetFocus
    ElseIf ComboBox1.Value = Empty Then
        MsgBox "FALTA ENTIDAD BANCARIA", vbCritical
        ComboBox1.SetFocus
    ElseIf ComboBox2.Value = Empty Then
        MsgBox "FALTA TIPO DE CUENTA", vbCritical
        ComboBox2.SetFocus
    ElseIf TextBox33.Value = Empty Then
        MsgBox "NÚMERO DE CUENTA", vbCritical
        TextBox33.SetFocus
    Else
  'llenar listbox
        ListBox3.AddItem TextBox34.Value
        ListBox3.List(ListBox3.ListCount - 1, 1) = TextBox35.Value
        ListBox3.List(ListBox3.ListCount - 1, 2) = ComboBox1.Value
        ListBox3.List(ListBox3.ListCount - 1, 3) = ComboBox2.Value
        ListBox3.List(ListBox3.ListCount - 1, 4) = TextBox33.Value
    End If
'cargar informacion ref bancaria a listbox
        
End Sub

 

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.