|
-
Jan 7th, 2012, 03:30 AM
#1
vbNewLine
This constant has me puzzled. The definition in the Object Browser is
Constant for NewLine; platform specific
which begs the question - What does 'platform' mean in this context?
(I'm not aware that VB code will run on Operating System 'platforms' other than the Windows family, except for, I guess, Windows emulators)
Even so, I can't see its value. If I create a file on Platform "X" where vbNewLine is defined as a Carriage Return and then try to read the file on Platform "Y" where vbNewLine is defined by a Carriage Return Line Feed pair I will have trouble (eg if I Split on vbNewLine I'll end up with one Array element) Porting a file from "Y" to "X" (and splitting on vbNewLine) would give extraneous LFs in the Array elements. That sorts out the 'specific' part of the definition.
Now, Microsoft wouldn't have gone to the bother if creating it if it wasn't useful(?)
Can anyone give me an example of the conditions where it's use would be more appropriate than the 'standard' CRLF pair? - I can't think of one. (perhaps I've just led a sheltered (programming) life )
Last edited by Doogle; Jan 7th, 2012 at 03:33 AM.
-
Jan 7th, 2012, 03:48 AM
#2
Re: vbNewLine
VB and VBA share common roots.
Mac editions of Office defined vbNewLine as CR or LF depending on the platform (Apple's old platform or the current BSD-derived platform). The point was to make the code portable, not the data files.
You could have a VBA macro in Excel that would process Windows data files on Windows and Mac data files on both flavors of Mac.
For whatever reason vbNewLine "runs faster" than vbCrLF in VB6 programs. It is also much better self-documentation to use vbNewLine when it represents a new line within text.
vbCrLf should basically never be used unless you want to force and imply that you are forcing CR/LF. A good example might be various Internet protocols, where by long-standing convention CR/LF is ALWAYS used as the "line delimiter" just as binary data ALWAYS uses big-endian order...
Except when people break the rules. The *nix johnnies have trashed the world in this regard. XML is fairly commonly shoveled across the 'Net using LF as new line. But you can't expect much from that lot anyway.
-
Jan 7th, 2012, 03:54 AM
#3
Re: vbNewLine
There are other curiosities in VB6 too, some working but pointless and other not working. Example, try:
Code:
MsgBox MacID("text")
Function MacID(Constant As String) As Long
Member of VBA.Conversion
Converts a four-character constant to a Macintosh file type or signature
This one seems entirely unfunctional:
Function MacScript(Script As String) As String
Member of VBA.Interaction
Executes an AppleScript script
Last edited by dilettante; Jan 7th, 2012 at 04:02 AM.
-
Jan 10th, 2012, 01:59 PM
#4
Re: vbNewLine
Dilletante: Thianks for that. I'd Rate your post but apparently I have to spread myself about a bit more !
-
Jan 10th, 2012, 05:06 PM
#5
Re: vbNewLine
We do what we can. I have the same problem and I need to "spread around" more myself.
-
Jan 12th, 2012, 12:58 PM
#6
Re: vbNewLine
Then there is Environment.NewLine in .NET
A string containing "\r\n" for non-Unix platforms, or a string containing "\n" for Unix platforms
-
Jan 12th, 2012, 05:26 PM
#7
Re: vbNewLine
 Originally Posted by Doogle
which begs the question - What does 'platform' mean in this context?
Maybe it is the same as this? Although, this one is for Java but you should get the idea.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|