Solved

From ListBox to Array Problem

Posted on 2006-07-18
8
213 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

751 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