How Do I Put An End Of Line Character In A TextBox

  • Thread starter Thread starter Christopher Lusardi
  • Start date Start date
C

Christopher Lusardi

With code such as the below how would I put an end of line character in
the 2nd line of:

Textbox1.Text = "Hello "
Textbox1.Text =
Textbox1.Text = "World"

Thanks,
Chris Lusardi
 
Assuming you are trying to display data on more than one line, you'd do
something like...

= "This is line 1." & chr(13) & chr(10) & "This is line 2."
 
Chris,

Actually, after running the three lines of code below, your TextBox would
only contain "World", as you are resetting the value each time.

Here are some constants you might find useful:
vbLF (Line Feed)
vbCR (Carriage Return)
vbCRLF (Carriage Return with Line Feed)

You can use them like this:
Textbox1.Text = "Hello " & vbCrLf & "World"

Or like this (note that the new values are being Appended to the previous
contents of the TextBox, not replacing the previous contents as your example
was doing):
Textbox1.Text = "Hello "
Textbox1.Text = Textbox1.Text & vbCrLf
Textbox1.Text = Textbox1.Text & "World"

-Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top