I want to use the Replace
function in VBScript to replace all line breaks in a string for "\n"
. I come from Java, so using \n
inside a string means a line break.
Is there an equivalent in VBScript?
If you want to force a new line in a message box, you can include one of the following: The Visual Basic for Applications constant for a carriage return and line feed, vbCrLf. The character codes for a carriage return and line feed, Chr(13) & Chr(10).
Features of VBScriptIt has a very simple syntax, easy to learn and to implement. Unlike C++ or Java, VBScript is an object-based scripting language and NOT an Object-Oriented Programming language. It uses Component Object Model (COM) in order to access the elements of the environment in which it is executing.
VBScript ("Microsoft Visual Basic Scripting Edition") is an Active Scripting language developed by Microsoft that is modeled on Visual Basic. It allows Microsoft Windows system administrators to generate powerful tools for managing computers with error handling, subroutines, and other advanced programming constructs.
For replace you can use vbCrLf
:
Replace(string, vbCrLf, "")
You can also use chr(13)+chr(10)
.
I seem to remember in some odd cases that chr(10)
comes before chr(13)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With