[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Easy List Box Question - Urgent

Posted on 2006-06-27
4
Medium Priority
?
201 Views
Last Modified: 2010-04-30
In vb6 I want to do something to each individual item within a list box..

eg:

   for each item in listbox1.items
      'mess about with the contents of that line
   next item

I do not know the correct syntax though..

Help
0
Comment
Question by:NAORC
[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 Comments
 
LVL 13

Accepted Solution

by:
jmundsack earned 500 total points
ID: 16994714
Dim i
For i = 0 To ListBox1.ListCount - 1
    MsgBox "The displayed item is " & ListBox1.List(i)
    MsgBox "The hidden, numeric value is " & ListBox1.ItemData(i)
Next i
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 16996279
Dim i as integer 'better coding
For i = 0 To ListBox1.ListCount - 1
    '-- Your stuff--
Next i
0
 
LVL 2

Expert Comment

by:davidnsc1
ID: 16996293
If you are going to be removing any, however, you're going to want to decrement i instead:
For i = ListBox1.ListCount - 1 to 0 step -1
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 16997141

Private Sub Form_Load()
Dim i As Long        'even better coding, because a long is faster as an integer!
For i = 9 To 15      'first fill the list with random data
   List1.AddItem i
Next

For i = 0 To List1.ListCount - 1
   List1.List(i) = "item: " & CStr(i)     'then assign new data
Next
End Sub
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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

649 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