Solved

I need to parse list box rows. VBA

Posted on 2008-06-11
6
1,368 Views
Last Modified: 2013-11-28
I have a multiple column list box. I need to iterate through each row and read the column values
What is the syntax?

For example:

Dim intCtr as integer
Dim strCol0Value as string
Dim strCol1Value as string

For intCtr=0 To listbox.Listcount -1
  strCol0Value =  MyValuelistbox (??)
  strCol1Value  MyValuelistbox (??)

Next intCtr

Or can I declare listbox items ?

For each item in listbox
   strCol0Value=??
   strCol0Value=??
Next item

thanks
0
Comment
Question by:Dovberman
  • 3
  • 3
6 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
Dovberman,

Why not just iterate through the Listbox's source Table (or Query)?

What exactly are you trying to accomplish here?

JeffCoachman
0
 

Author Comment

by:Dovberman
Comment Utility
The source is a value list. There are 2 list boxes. One contains all available choices. The other contains the choices that were selected from list 1.

I need to update a table based on the items in list 2.
0
 

Author Comment

by:Dovberman
Comment Utility
I found code for parsing and finding selected rows. Since all rows need to be read, I can remove the selected criteria.

  For intCtr = 0 To lstApplicants.ListCount - 1
        'isSelected = lstApplicants.Selected(intCtr)
        'If isSelected Then
             lstApplicants.ItemData (intCtr) ' returns the data from column 0
            'Do Stuff
        End If
     Next
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 250 total points
Comment Utility
Dovberman,

If this is a multi-select listbox, you can use code like this to "de-select all the selected rows:

Dim varItem As Variant
Dim ctl As Control

Set ctl = Me.lstCustomers

    'Loops through all the Items and turns them off
    For Each varItem In ctl.ItemsSelected
        ctl.Selected(varItem) = False
    Next varItem

You will have to modify the object names to match yours.

JeffCoachman
0
 

Author Closing Comment

by:Dovberman
Comment Utility
Thanks for the extra information
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
;-)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

763 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

12 Experts available now in Live!

Get 1:1 Help Now