Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
also note that Chr(10) equals vbCrLf
No, Chr(10) does not equal vbCrLf, rather, it equals the predefined string constant vbLf. The Cr in vbCrLf stands for Carriage Return while the Lf stands for Line Feed... vbCrLf is a predefined two-character string constant whose first character as an ASCII code of 13 and whose second character has an ASCII code of 10. Excel uses vbLf (character with ASCII code of 10) for its newline character. If you use vbCrLf, the Carriage Return character remains, but being a non-printing character, you can't easily see it. Go into the VB editor and execute this line of code in the Immediate Window... Range("A1").Value = "One" & vbCrLf & "Two" Then select the cell and put the cursor in the Formula Bar... click it so that it is to the right of the word One on the first line and make sure it is not next to the "e" when you click it... you will see what looks like a "space" after the "e"... that is the Carriage Return character. Excel and VB pretty much use the Line Feed (vbLf) character for its newline character. So, you might ask, what is the vbCrLf character sequence for? It is the character sequence that Windows (and DOS before it) uses for its newline character sequence. If you were to read in an entire text file stored on the hard disk into a String variable, you would find the Carriage Return/Line Feed character sequence everywhere there is a new line in the text file. It might be useful to know that Mac computers (at least the older operating system) use a Carriage Return for its text file newlines (UNIX/Linux uses the Line Feed for its newline which, since the newer Mac OS is Linux based, as I understand it, is why I am unsure what its newer OS uses for newlines). There is a universal predefined VB constant that automatically adjusts itself to be the proper newline character (sequence) for Macs and PCs... vbNewLine... it is equivalent to vbCrLf on a PC and vbCr on a Mac (at least for the older OSs... and possibly vbLf for the new OSs, but not being a Mac person, I'm not sure of this latter possibility... it may be vbCr for all Macs... I have no way of checking). Rick Rothstein (MVP - Excel) |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Use CountIf for a literal string | Excel Worksheet Functions | |||
Excel 2003 - hyperlink to a location in the same file | Excel Discussion (Misc queries) | |||
Excel: Use pic location string to call up picuture in cell? | Excel Discussion (Misc queries) | |||
Exctracting Literal Value From A String Variable | Excel Programming | |||
Exctracting Literal Value From A String Variable | Excel Programming |