what is the most efficient way to convert an array into string

Posted on 2007-07-24
Last Modified: 2010-04-23
       Dim intArr() = {1, 2, 3}

        MsgBox(Convert.ToString(intArr)) does not work
        MsgBox(Convert.ToString(CObj(intArr))) either

Question by:AlexF777
    LVL 18

    Assisted Solution

    If you have three array items thn you have to output them as follows


    Or if you want to convert the array to 'String' type

    This might work

    Dim arrStr() as string = CType(intArr, String)
    LVL 27

    Assisted Solution

    You can just use the Join method:

        MsgBox(Join(intArr, ","))

    LVL 27

    Accepted Solution

    You know, if your array is of the Type Integer, then you may need to take this kind of an approach:

        'This sub is not required, but put the code in whatever sub you want to show the message in.
        Private Sub ShowArray()
            Dim intArr() As Integer = {1, 2, 3}
            Dim str As String() = Array.ConvertAll(Of Integer, String)(intArr, AddressOf IntToString)

            MsgBox(Join(str, ","))

        End Sub

        'This sub is required
        Private Shared Function IntToString(ByVal i As Integer) As String

            Return CType(i, String)

        End Function


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    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

    16 Experts available now in Live!

    Get 1:1 Help Now