Results 1 to 2 of 2

Thread: How to create one long string from a collection of values

  1. #1

    Thread Starter
    Member Comn8u's Avatar
    Join Date
    Jul 2004
    Posts
    35

    How to create one long string from a collection of values

    How to create one long string from a collection of values
    How would I create one long string from a collection of values? What I mean by this is - say that you have a listbox of e-mail addresses and you want to be able to put them all together with semi-colons after them and into one string that will be used as an e-mail address.

    (e.g.)
    LIST BOX:
    [email protected]
    [email protected]
    [email protected]
    [email protected]



    String:
    [email protected]; [email protected]; [email protected]; [email protected]

  2. #2
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    Here you go, don't know what language you're using so it's in VB.
    VB Code:
    1. Dim i As Short
    2.         Dim strText as String
    3.        
    4. For i = 0 To ListBox1.Items.Count - 1
    5.             strText &= ListBox1.Items(i).ToString
    6.             If Not i = ListBox1.Items.Count - 1 Then
    7.                 strText &= ";"
    8.             End If
    9.         Next
    Last edited by Fishcake; Jul 25th, 2004 at 05:19 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width