ListBox Items collection to String Array in VB.NET 1.1

Posted on 2007-08-09
Last Modified: 2013-11-26

Here is a helper function I have that I use to return the elements of a list box as a string array.  Is there a better way ?


        Public Shared Function ReturnListBoxItemsAtStringArray(ByVal theListBox As Windows.Forms.ListBox) As String()
            Dim strArr As String()
            ReDim strArr(theListBox.Items.Count - 1)
            theListBox.Items.CopyTo(strArr, 0)
            ReturnListBoxItemsAtStringArray = strArr
        End Function
Question by:orekin
    1 Comment
    LVL 96

    Accepted Solution

    No, that's pretty good already.


    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
    This is an explanation of a simple data model to help parse a JSON feed
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    732 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

    24 Experts available now in Live!

    Get 1:1 Help Now