Link to home
Start Free TrialLog in
Avatar of Dovberman
DovbermanFlag for United States of America

asked on

I need to parse list box rows. VBA

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
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Dovberman,

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

What exactly are you trying to accomplish here?

JeffCoachman
Avatar of Dovberman

ASKER

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.
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
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the extra information