Results 1 to 3 of 3

Thread: Extracting from string

  1. #1

    Thread Starter
    Registered User
    Join Date
    Sep 2002
    Posts
    221

    Extracting from string

    Hi

    Can someone show me how to split a string and display each word in a label control?

    For example, if I enter the name "Jenny Smith Kline" in a text box, I want to be able to get each name and display it in a different label control.

    I know how to do it if there are only 2 names, e.g. "Jenny Smith", You just search for the "space" using the "instr" function.

    I cant seem to do it with 3 names?

    Please help
    Last edited by jennysmith; Apr 11th, 2004 at 05:02 PM.

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    You can use Split().

    VB Code:
    1. Dim str As String = "Jenny Smith Kline"
    2.  
    3. Dim parts() As String = str.Split(Char.Parse(" "))
    4.  
    5. Label1.Text = parts(0)
    6. Label2.Text = parts(1)
    7. Label3.Text = parts(2)


    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Registered User
    Join Date
    Sep 2002
    Posts
    221
    Wow, that code is cool, thanks

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