(Uh, CR/LF means Carriage Return/Linefeed.)
The codes for this are
Hex | Decimal | Visual Basic | Delphi | C++ Builder | Java | Paradox | |
---|---|---|---|---|---|---|---|
CR | 0D | 13 | vbCR | #13 | \r | ||
LF | 0A | 10 | vbLF | #10 | |||
CR/LF | 0D0A | 13,10 | vbCRLF vbNewLine | #13#10 | \n | newLine() | \n |
Tab | 09 | 9 | vbTab | #9 | \t |
Well, there is more - the line termination character sequence is operating system dependent. The C \n, the VisualBasic vbNewLine, and the Java newLine() will be interpreted according to the following table.
Operating Environment | Sequence |
---|---|
MS DOS/MS Windows | CRLF |
Unix | LF |
Macintosh | CR |
As a result, moving "straight text" files between systems can cause pretty severe problems. (In windows, DOS Edit and WinWord convert unix line terminators to DOS line terminators, but notepad just shows the unix teminators as boxes.)
VisualBasic 3.0 VisualBasic 6.0 ESC$ = Chr$(KEY_ESCAPE) ESC$ = Chr$(vbKeyEscape) cr$ = Chr$(KEY_RETURN) cr$ = Chr$(vbKeyReturn)GlobalConstants.bas is a fully functional and tested module which defines the global variables
esc$, cr$, lf$, crlf$
tempStr$ = "Line 1" & crlf$ & "Line 2"MS Access 97 and VBA (Visual Basic for Applications) allows vbCR, vbLF, vbCRLF. However, it is not clear if VB supports these.
I'm not sure which versions of VisualBasic and VBA support vbNewLine - it is supported in ASP VBScript.
From ibutils.pas
const CRLF = #13 + #10; CR = #13; LF = #10; TAB = #9; NULL_TERMINATOR = #0;From Character String help
tempStr := 'Line 1'#13#10'Line 2';
You can also specify characters using hex
const CRLF = #$D#$A; CR = #$D; LF = #$A;
tempStr = "Line 1\nLine 2";
A newLine() method is provided, which uses the platform's own notion of line separator as defined by the system property line.separator. Not all platforms use the newline character ('\n') to terminate lines. Calling this method to terminate each output line is therefore preferred to writing a newline character directly. sun.comOn the other hand, in its Dialog Box Tutorial, Sun says
You can split the message over several lines by putting newline (\n) characters inside the message string. For example:Who knows what to believe. I've seen \n fail in text fields."Complete the sentence:\n \"Green eggs and...\""