Results 1 to 4 of 4

Thread: [RESOLVED] Multiline textbox

  1. #1

    Thread Starter
    Addicted Member Fonty's Avatar
    Join Date
    May 2006
    Location
    New York
    Posts
    173

    Resolved [RESOLVED] Multiline textbox

    Suppose you populate two cells:

    Range("A1").text = "This is the first line"
    Range("A2").text = "This is the second line"

    Then you have a textbox and you set the multiline property to true. How can you fill the textbox so that you see both cells in two separate lines like:

    This is the first line
    This is the second line

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Multiline textbox

    Code:
    Textbox1.Text = Range("A1").Value & Chr(10) & Range("A2").Value
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    Addicted Member
    Join Date
    Apr 2009
    Location
    Toronto, Ontario
    Posts
    242

    Re: Multiline textbox

    Hi,
    Not to tread on any toes koolsid, but that will not work. A new line in Windows needs both CR and LF and your code only puts LF.

    Using vbCrLf solves all!

    Code:
    Textbox1.Text = Range("A1").Value & vbCrLf & Range("A2").Value
    or of course you could also use:
    Code:
    Textbox1.Text = Range("A1").Value & Chr(13) & Chr(10) & Range("A2").Value
    Cheers.
    -EM
    ---
    REMEMBER: If your issue is resolved, use the Thread Tools menu to set it as such, and be sure to rate the posts that help you the most!


    Just because I was jealous of g4hsean!

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Multiline textbox

    Or you could use
    Code:
    TextBox1.Text = Range("A1").Value & vbNewLine & Range("A2").Value

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