Line break: vbNewLine vs. vbCrLf vs. vbCr vs. vbLf

Line break: vbNewLine vs. vbCrLf vs. vbCr vs. vbLf

DRoam
Mentor Mentor
11,702 Views
3 Replies
Message 1 of 4

Line break: vbNewLine vs. vbCrLf vs. vbCr vs. vbLf

DRoam
Mentor
Mentor

I have a vague understanding of what "Cr" (carriage return) and "Lf" (line feed) mean (or, at least, what people on internet forms think they mean)... what I'd like to know is, specifically in Inventor, is there any reason to use (or not use) any of them in particular?

 

I'm asking because I've always used vbnewline but seem to invariably type "vbnewlein" more than half the time.

 

In iLogic and Inventor's VBA specifically, is there any reason not to use the more succinct vbCrLf, or even vbLf or vbCr?

 

Oh, and I'm asking in regards to their use in MessageBoxes, strings, and even output to text files via, for example, System.IO.File.WriteAllText.

0 Likes
Accepted solutions (1)
11,703 Views
3 Replies
Replies (3)
Message 2 of 4

DRoam
Mentor
Mentor

Just answered part of my question with a quick test. While vbCrLf and vbNewLine (and also Environment.NewLine) result in a proper line break when exported to a text file with WriteAllText, vbLf and vbCr do not.

 

So it's down to vbNewLine and vbCrLf.

 

So, any reason not to use vbCrLf over vbNewLine?

0 Likes
Message 3 of 4

JamieVJohnson2
Collaborator
Collaborator
Accepted solution

From:

https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.constants.vbcrlf?view=netframework...

 

vbCrLf :  Represents a carriage-return character combined with a linefeed character for print and display functions.

 

Also it states vbNewLine is now obsolete.

 

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
Message 4 of 4

DRoam
Mentor
Mentor

I didn't even think to check the actual official documentation...

 

That about settles it! Glad it's the one that's faster to type that's still supported 😉

 

Thanks!