Results 1 to 9 of 9

Thread: [2.0] Newline?

  1. #1

    Thread Starter
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    [2.0] Newline?

    I have a multiline textbox, which the user would type something into and press a button. The button does something with the text, depending on which characters are used. But i can't work out how to recognise a newline in the textbox. I thought i could do this:

    Code:
    if (tbxIn.Text[i] == Convert.ToChar(Environment.NewLine))
    {
          // action here...
    }

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2.0] Newline?

    Look for \n or \r

  3. #3

    Thread Starter
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    Re: [2.0] Newline?

    Insted of getting this:

    1st Line
    2nd Line

    I get this:

    1st Line□2nd Line

  4. #4

    Thread Starter
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    Re: [2.0] Newline?

    It would probably help if you could see what i needed it for:

    The parts i need help with is in _Encrypt and _Decrypt procedures.
    Ive attatched the project (without an EXE).
    Attached Files Attached Files

  5. #5
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: [2.0] Newline?

    Code:
    if (tbxIn.Text[i] == '\n')
    {
          // action here...
    }
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  6. #6

    Thread Starter
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    Re: [2.0] Newline?

    I tried that. I got this effect:

    Code:
    1st Line□2nd Line

  7. #7

    Thread Starter
    Hyperactive Member francisstokes's Avatar
    Join Date
    May 2005
    Location
    Kent, England
    Posts
    272

    Re: [2.0] Newline?

    I fixed it. Used RTB's insted of standard textboxs (which i was trying to avoid, but it doesnt really matter ). Thanks for all the help.

  8. #8
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: [2.0] Newline?

    I guess I'm late for that but try the string "\r\n" instead of '\n' only
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

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

    Re: [2.0] Newline?

    As a little more explanation, Environment.NewLine is two character string containing a carriage return character ('\r') and a line feed character ('\n'). If you convert that to a char then you simply drop the line feed and get the carriage return. You haven't really specified what you're trying to do but you may be interested to know that both the TextBox and RichTextBox have a Lines property, which returns a string array of the Text split on the 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

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