Solved

From ListBox to Array Problem

Posted on 2006-07-18
8
204 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 143

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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 143

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
 
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 143

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 143

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Copy a row 12 64
MS Date Picker 64 bit 32 bit issue 12 61
Automatic Email Reminder 4 58
VBA: loop recent folder and copy txt file. 8 36
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 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