Visual Basic - problema seleccion multiple fileListBox

Life is soft - evento anual de software empresarial
 
Vista:

problema seleccion multiple fileListBox

Publicado por Esteban (5 intervenciones) el 05/04/2010 01:57:53
Hola...no tengo mucha idea de VB, por eso tiro esta consulta. Tengo que elegir varios elementos de un fileListBox y que me los pase a un vector, y que luego los guarde en otro lado...el problema que tengo es que me guarda solamente uno de ellos. Es decir, elijo 5 elementos de la lista, pero me guarda solamente uno, el último que seleccioné, 5 veces. Busqué en varios foros y no encontré nada que lo solucione. Si alguien me puede dar una mano, chas 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

seleccion multiple fileListBox

Publicado por amelia (60 intervenciones) el 16/04/2010 19:48:25
J = 0
k = 0
Searchchar = " *"
For i = 0 To List1.ListCount - 1
a = InStr(1, List1.List(i), Searchchar, vbTextCompare)
m_len = Len(List1.List(i))
m_descripcion = Left(List1.List(i), a - 1)
m_item = Right(List1.List(i), m_len - (a + 9))
m_antdescripcion = m_descripcion

Do While m_descripcion = m_antdescripcion
If List1.Selected(i) Then
If t = 0 Then
adescripcion(k, 0) = m_descripcion
conectar
Set rsttemp = Nothing
tsql = "Select cert from tabdescripcion where (documento = 'OC' and descripcion= " & "'" & m_descripcion & "'" & " and pedido = " & fpedido & ")"
rsttemp.CursorLocation = adUseClient
rsttemp.Open tsql, strcnn, adOpenKeyset, adLockOptimistic, adCmdText
desconectar
adescripcion(k, 1) = rsttemp!cert

t = 1
End If


conectar
Set rstcarga = Nothing
strcarga = "Select * from tabitem where (documento = 'OC' and descripcion= " & "'" & m_descripcion & "'" & " and item = " & "'" & m_item & "'" & ")"
rstcarga.CursorLocation = adUseClient
rstcarga.Open strcarga, strcnn, adOpenKeyset, adLockOptimistic, adCmdText
desconectar

aitem(J, 0) = rstcarga!Item
aitem(J, 1) = rstcarga!med1
aitem(J, 2) = rstcarga!med2
aitem(J, 3) = rstcarga!med3
aitem(J, 4) = rstcarga!origin
aitem(J, 5) = rstcarga!yitem
aitem(J, 6) = rstcarga!quantity
aitem(J, 7) = rstcarga!qu
aitem(J, 8) = rstcarga!Weight
aitem(J, 9) = rstcarga!price
aitem(J, 10) = rstcarga!pu
aitem(J, 11) = rstcarga!totalitem
aitem(J, 12) = rstcarga!descripcion
J = J + 1
i = i + 1
If i = List1.ListCount Then

Exit Do
End If
a = InStr(1, List1.List(i), Searchchar, vbTextCompare)
m_len = Len(List1.List(i))
m_antdescripcion = m_descripcion
m_descripcion = Left(List1.List(i), a - 1)
m_item = Right(List1.List(i), m_len - (a + 9))

Else
i = i + 1
If i = List1.ListCount Then

Exit Do
End If
a = InStr(1, List1.List(i), Searchchar, vbTextCompare)
m_len = Len(List1.List(i))
m_antdescripcion = m_descripcion
m_descripcion = Left(List1.List(i), a - 1)
m_item = Right(List1.List(i), m_len - (a + 9))
If i = List1.ListCount Then

Exit Do
End If

End If
Loop
i = i - 1
t = 0

If i = List1.ListCount Then

Exit For
End If

Next i
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: seleccion multiple fileListBox

Publicado por Esteban (5 intervenciones) el 16/04/2010 22:58:57
Gracia Amelia
Al final lo pude solucionar...pasa que es muy difícil de explicar...lo que hacía mal era que guardaba siempre el último ítem seleccionado de la lista, pero era así porque estaba hecho así, y lo estaba modificando para que haga la selección múltiple también. Como guardaba sólo uno antes de mi modificación, usaba una ruta x, que era la que indicaba la ubicación del elemento donde se había hecho click por última vez. Lo único que tenía que hacer era crear otra ruta que vaya tomando los datos del archivo en caso de estar seleccionado, dentro del ciclo ese. Y bueno, lo solucioné hace como dos semanas ya, pero igual gracias je...
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