Solved

From ListBox to Array Problem

Posted on 2006-07-18
8
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

624 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