Results 1 to 8 of 8

Thread: New Line in strings

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Chicagoland
    Posts
    92

    New Line in strings

    I'm reading text out of a text file and I want to put it into a ToolTip control with multiple lines. I have control over the text file, so I can format it anyway I want. The text file would look something like this:

    Code:
    line 1 vbcrlf line 2
    I want to read it in a line at a time and assign it to the tooltip. Something like:

    VB Code:
    1. Dim str as String = sr.Readline
    2.  
    3. ToolTip1.SetToolTip(TextBox1, str)

    Then when the cursor is on TextBox1, I want it to show
    Code:
    line 1
    line 2
    rather than what it looks like in the textfile. I guess I need some kind of escape sequence, but I'm not sure how to do it.

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    This code gives you a tooltip split over two lines.

    What are you having problems with? Are you not able to replace the CR/LF character from your text file with a vbCrLf?

    VB Code:
    1. ToolTip1.SetToolTip(TextBox1, "first" & vbCrLf & "second")
    This world is not my home. I'm just passing through.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Chicagoland
    Posts
    92
    I know I could split it up and do what you said, but I was hoping for something easier.

    I once heard that the best programmers are lazy. If so, I'm the best damn programmer in the world.

  4. #4
    Member McBain2's Avatar
    Join Date
    Sep 2003
    Location
    UK, Glos.
    Posts
    60
    Think I understand you....

    If so you want to do this after reading the line from the file and before assigning it to the tooltip...
    VB Code:
    1. str = str.Replace("vbcrlf", vbCrLf)

  5. #5
    Addicted Member dani2's Avatar
    Join Date
    Feb 2005
    Location
    Sibiu.ro
    Posts
    191

    Re: New Line in strings

    Quote Originally Posted by McBain2
    Think I understand you....

    If so you want to do this after reading the line from the file and before assigning it to the tooltip...
    VB Code:
    1. str = str.Replace("vbcrlf", vbCrLf)
    Hey! The vbCrLf thing does not work..or am i missing something?
    Home is where your Head is

  6. #6
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: New Line in strings

    Use Environment.NewLine instead of VBCrLf

    Edit--
    wossname
    Last edited by Shuja Ali; Jun 28th, 2006 at 06:44 AM.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  7. #7
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: New Line in strings

    Use Environment.Newline instead of vbCRLF.
    I don't live here any more.

  8. #8
    Addicted Member dani2's Avatar
    Join Date
    Feb 2005
    Location
    Sibiu.ro
    Posts
    191

    Re: New Line in strings

    Quote Originally Posted by wossname
    Use Environment.Newline instead of vbCRLF.
    yes i figured that out
    thank you
    Home is where your Head is

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