?
Solved

I need to parse list box rows. VBA

Posted on 2008-06-11
6
Medium Priority
?
1,386 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
[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
  • 3
  • 3
6 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 21764588
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
ID: 21767453
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
ID: 21767477
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 1000 total points
ID: 21770047
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
ID: 31466320
Thanks for the extra information
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 21774678
;-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Suggested Courses

752 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