Featured Replies
Archivado
Este tema está ahora archivado y está cerrado a más respuestas.
A better way to browse. Learn more.
A full-screen app on your home screen with push notifications, badges and more.
Este tema está ahora archivado y está cerrado a más respuestas.
Hola buenas, estoy intentando pasar un listbox a una función que me sume los valores de una de las columnas del listbox, pero aunque tenga datos me dice que recibe null, que el listbox vale null. No puedo entender lo que pasa ya que el mismo listbox lo paso a otra función en el mismo método para ver si existe un valor introducido y si que funciona.
Private Sub bnt_ADD_TQ_Click() If Me.txt_DESCRIPCION_TQ.Text = Empty Or Me.txt_PRECIO_TQ.Text = Empty Then MsgBox ("Te has olvidado de introducir algún dato.") Else If Me.lst_TIQUETS.ListCount = 0 Then Me.lst_TIQUETS.AddItem Me.lst_TIQUETS.List(Q, 0) = Me.txt_DESCRIPCION_TQ.Text Me.lst_TIQUETS.List(Q, 1) = Me.txt_PRECIO_TQ.Value Q = Q + 1 Me.txt_DESCRIPCION_TQ.Text = Empty Me.txt_PRECIO_TQ.Text = Empty Me.txt_SUMA_TIQUETS.Value = suma(lst_TIQUETS) Else If existe(Me.txt_DESCRIPCION_TQ.Text, Me.lst_TIQUETS) = True Then MsgBox ("Ya has introducido un tiquet con esa descripción, si tienes dos iguales cambia la descrición.") Exit Sub Else Me.lst_TIQUETS.AddItem Me.lst_TIQUETS.List(Q, 0) = Me.txt_DESCRIPCION_TQ.Text Me.lst_TIQUETS.List(Q, 1) = Me.txt_PRECIO_TQ.Value Q = Q + 1 Me.txt_DESCRIPCION_TQ.Text = Empty Me.txt_PRECIO_TQ.Text = Empty Me.txt_SUMA_TIQUETS.Value = suma(lst_TIQUETS) End If End If End If End Sub
dejo las dos funciones, una funciona y la otra no???? las dos se llaman en el mismo método.
Private Function existe(Descripcion As String, lista As MSForms.ListBox) As Boolean Dim i As Integer For i = 0 To lista.ListCount - 1 If lista.List(i, 0) = Descripcion Then existe = True Exit Function End If Next existe = False End Function Private Function suma(lista As MSForms.ListBox) As Double Dim i As Integer If Not lista = Null Then For i = 0 To lista.ListCount - 1 suma = suma + Val(lista.List(i, 1)) Next End If End Function
Muchas gracias por la ayuda, saludos