LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Excel 2003 VBA string literal help location

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Use CountIf for a literal string chadkwelch Excel Worksheet Functions 3 March 21st 10 03:45 AM
Excel 2003 - hyperlink to a location in the same file Silverstreak Excel Discussion (Misc queries) 1 June 30th 09 02:33 PM
Excel: Use pic location string to call up picuture in cell? vloh28 Excel Discussion (Misc queries) 1 October 30th 07 12:42 AM
Exctracting Literal Value From A String Variable rocketslinger[_6_] Excel Programming 3 March 8th 06 03:15 PM
Exctracting Literal Value From A String Variable rocketslinger[_5_] Excel Programming 0 March 8th 06 12:59 AM


All times are GMT +1. The time now is 07:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"