|
How do I add a new line character to a string in VB? (VB.Net) |
|
|
Written by: Justin Rich
How do I add a new line character to a string in VB?In Visual Basic.Net, the new line character is vbCrLf or vbNewLine.
Dim strNewLine as String = "This is a line." & vbCrLf Dim strNewLine2 as String = "This ia a line." & vbNewLine
vbCrLf stands for Visual Basic Carriage Return Line Feed. This sounds like something you would do on a typewriter, which is essentially true and goes back to the early 90's when Visual Bascic was in is first few versions. Modern languages call it a new line character and with Visual Basic.Net, the vbNewLine was introduced.
There are alternative renditions of this such as vbCr and vbLf separately, but I would suggest always using vbCrLf or vbNewLine to ensure it works cross platform.
If you're generating an HTML output from a post or something that read in all of the line feeds (or new lines) then you'll want to use the .Replace function (or simply Replace) to swap the vbCrLf with <br> tags.
|
|
|
|
|
|