chr(10) and chr(13)

E

ela

just want to know what are these characters are for?
where and when to use them in the code?

thanks!
 
T

Tom Lake

ela said:
just want to know what are these characters are for?
where and when to use them in the code?

Chr(10) is a line feed and Chr(13) is a carriage return. If you want to put
line breaks in your text, you can use these.

a$ = "This is a" & Chr(10) & "line feed"

gives:

This is a
line feed


Tom Lake
 
W

Wayne Morgan

Tom is correct. In the VBA editor, you can use vbCrLf (Carriage Return, Line
Feed) instead of the Chr entries. It is a built-in constant. However, in
calculated textboxes you have to use the Chr commands because they don't
recognize VBA's built-in constants.
 
J

John Vinson

just want to know what are these characters are for?
where and when to use them in the code?

thanks!

Just to add one (slightly peculiar) bit of information - in Windows,
the end of one line and the beginning of another is stored as these
two characters in the order Chr(13) & Chr(10) - a carriage return
followed by a line feed. You need both, and you need them in that
order to (say) put a two-line message into a textbox or label.

John W. Vinson[MVP]
 
E

Ed Warren

Or you can use the "ctrl + return" key on the keyboard to enter them in the
textbox and/or calculated control.

Example I was just working on: I wanted the following presented at the top
of a report the dates come from a form that then calls the report.

Report for dates
between
1/1/2005 and 3/1/2005

TextBoxHeader
Data : = "Report for Dates (ctl+return key)between (ctl+return key)" &
Forms![CallingForm].StartDate & " and " Forms![CallingForm].EndDate

or using chr(xx)
Data : = "Report for Dates " & Chr(13) & Chr(10) & "between " & Chr(13) &
Chr(10) & Forms![CallingForm].StartDate & " and "
Forms![CallingForm].EndDate

Ed Warren
 
Top