Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Carraige return & Line feed 1

Status
Not open for further replies.

ecugrad

MIS
Apr 17, 2001
191
US
How do I add a carraige return & Line feed to a multiple line text box. I read a previous post of how to strip one out bul not how to code one in..

Thanks...
 
Here's an example:

Text1.Text = "Line 1" & vbCrLf & "Line2"
 
Another bit of info to be aware of is the use of "Chr(10)" which is the carriage return character.

This can be used for a Message Box, as follows:

Sub Message_Box2()
text1 = "Line 1" & Chr(10) & "Line 2"
MsgBox text1
End Sub

But it can ALSO be used if you ever want to do a Search & Replace to remove carriage returns from multiple text boxes.

This situation came up in a previous posting where I had recommended the following routine, which will eliminate carriage returns in whatever range is highlighted.

Sub Remove_Carriage_Returns()
Selection.Replace What:="" & Chr(10) & "", Replacement:=" ", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False
End Sub

However, in re-reading your description, I now see that you are referring to forcing a carriage return in a "text box".

Therefore, you possibly are only wanting to know the "manual" method of forcing a carriage return.

This is done by simply... holding down the <Shift> key and hitting <Enter>.

Hope this helps. :)

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
A big star to you, Dale. You consistently do one of the best and most thorough jobs of explaining your responses.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top