Solved

From ListBox to Array Problem

Posted on 2006-07-18
8
187 Views
Last Modified: 2010-04-30
Hi experts,

I'm getting selected items from listbox and populating an array with them. I want to get all of listbox items if nothing is selected and populate the same array with them. What do I need to add to my code? Thanks.

    For i = 0 To Me.Client_List.ListCount - 1
        If Me.Client_List.Selected(i) Then
            c = c + 1
            ReDim Preserve Clients(1 To c) As Integer
            Clients(c) = Me.Client_List.ItemData(i)
        End If
    Next i
0
Comment
Question by:RealSnaD
  • 4
  • 3
8 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17131725
   For i = 0 To Me.Client_List.ListCount - 1
        If Me.Client_List.Selected(i) or me.Client_List.SelCount = 0 Then
            c = c + 1
            ReDim Preserve Clients(1 To c) As Integer
            Clients(c) = Me.Client_List.ItemData(i)
        End If
    Next i
0
 
LVL 7

Author Comment

by:RealSnaD
ID: 17131771
Nope, method or data member SelCount is not found
0
 
LVL 7

Author Comment

by:RealSnaD
ID: 17131837
I also tried ItemsSelected. Didn't work either.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17131869
Well, in my vb6 listbox it works, so either
* you have vb.net
* you are using listview
please specify
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 7

Author Comment

by:RealSnaD
ID: 17131953
actually, im using ms access. it has vb 6.3. and i am using listbox for sure. just checked.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 17132250
vba?
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 17132471
For i = 0 To Me.Client_List.ListCount - 1
        If Me.Client_List.Selected(i) or me.Client_List.ItemsSelect.count = 0 Then
            c = c + 1
            ReDim Preserve Clients(1 To c) As Integer
            Clients(c) = Me.Client_List.ItemData(i)
        End If
    Next i

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 17132482
otherwise:

For i = 0 To Me.Client_List.ListCount - 1
        If Me.Client_List.Selected(i) Then
            c = c + 1
            ReDim Preserve Clients(1 To c) As Integer
            Clients(c) = Me.Client_List.ItemData(i)
        End If
    Next i

if c = 0 then
  c =  Me.Client_List.ListCount
  ReDim Preserve Clients(1 To c) As Integer
  For i = 0 To Me.Client_List.ListCount - 1
    Clients(i+1) = Me.Client_List.ItemData(i)
  Next i
End if
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now