Results 1 to 5 of 5

Thread: Parsing text

  1. #1

    Thread Starter
    Lively Member safewithyou247's Avatar
    Join Date
    Dec 2005
    Posts
    64

    Exclamation Parsing text

    I have a form that has a textbox where I want users to copy a pre-defined template into. The template will look something like this:

    First Name: Bla
    Last Name: Bla-Bla
    Email: [email protected]


    and so on. What I want to do is then read through this text line by line and put each description into seperate variables. How do I accomplish this?

    Thanks in advance for any help.
    "A candle loses nothing by lighting another candle."

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Parsing text

    Why dont you just have them enter the text into three seperate textboxes?? Saves you from having to parse it out, as each one would be in its own textbox...

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Parsing text

    As Gig suggests, seperate controls is more appropriate. You should use three Labels and three TextBoxes. It would then be easy to validate the format of the e-mail address using a Regex as well. If you are determined to use a single TextBox then you would use the Lines property, which is an array of strings that is basically the Text split on line breaks.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Lively Member safewithyou247's Avatar
    Join Date
    Dec 2005
    Posts
    64

    Re: Parsing text

    Can you give me an example of how I would use the lines feature to accoplish this?

    As far as the individual text boxs that will come later this is something for a type of automation.

    Thanks
    "A candle loses nothing by lighting another candle."

  5. #5
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Parsing text

    The lines is just a property of the textbox... it is a string array... you just refer to the index of the line you want... like below:
    VB Code:
    1. MessageBox.Show(TextBox1.Lines(0))
    2.         MessageBox.Show(TextBox1.Lines(1))

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