www.webdeveloper.com
Results 1 to 3 of 3

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

  1. #1
    Join Date
    Jul 2004
    Posts
    61

    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:
    user@domain.com
    user1@domain.com
    user2@domain.com
    user3@domain.com



    String:
    user@domain.com; user1@domain.com; user2@domain.com; user3@domain.com





    Thank you all for your comments, its really helped me out tremendously!

  2. #2
    Join Date
    Feb 2004
    Posts
    19
    If you have filled your DropDownList using a DataSet it will be easier, what you have to do is this:

    Dim X as Integer
    Dim YourLongString as String

    For X = 0 to Data_Set_Emails.Rows.Count()
    YourLongString = DataSet_Emails.Tables("Emails").Rows(x)("email")
    Next
    Last edited by enb141; 07-27-2004 at 03:56 PM.

  3. #3
    Join Date
    Jul 2004
    Location
    The Hague, the Netherlands
    Posts
    22
    If you have a listbox called lstEmail:

    Dim s As String = ""
    Dim i As Int16
    For i = 0 To lstEmail.Items.Count - 1
    s &= lstEmail.Items(i).ToString() & "; "
    Next
    's = the string
    MessageBox.Show(s)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles