list items that are selected in a listbox....

Posted on 2005-04-28
Last Modified: 2010-05-02
I'm trying the following code to list the data presented in a list box.  But I don't get the actual text that I'm searching for...
It's a list box of paths to various drawings!  When I run it I get various numbers...  There are no columns associated with this if I'm correct.

For n = 0 To frmList.lstPaths.ListCount - 1

If frmList.lstPaths.Selected(n) = True Then myItem = frmList.lstPaths.ItemData(n)

MsgBox myItem

next n
Question by:stephenlecomptejr
    LVL 18

    Accepted Solution

       Dim n As Long
        Dim myItem As String
        For n = 0 To frmList.lstPaths.ListCount - 1
            If frmList.lstPaths.Selected(n) = True Then
                myItem = frmList.lstPaths.List(n)
                MsgBox myItem
            End If
        Next n
    LVL 1

    Author Comment

    thank you for asking such a ridiculous question.
    LVL 1

    Author Comment

    I meant thank your answering such a ridiculous question...
    wasn't sure...since was not working because of another glitch...
    kinda stressed out. ***

    Thanks again.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    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…

    745 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

    14 Experts available now in Live!

    Get 1:1 Help Now