June 10th, 2003, 12:33 AM
how to do a new line in vbscript
Either I'm really dumb, or VBScript is a piece of sh*t. How do you write something in a new line? In every other language, it's \n. I looked it up on Google, and it seems to be the code vbcr. However, this only returns a white space. I need a NEW LINE. So far, nothing seems to do it!
June 10th, 2003, 12:35 AM
Ah okay, I figured you could do the html trick response.write("<br>"), but I would have thought vbscript would probably provide a line break function. oh well.
June 10th, 2003, 08:29 AM
Well, there is a difference between a new line (vbCr or vbCrLf) and the html code <br>.
If you view the source you will most likely see where your new line character was placed, but browsers do not acknowledge new lines since it is a tag based language. In most scripting languages you will have to write the <br> tag instead of using a new line character.
June 10th, 2003, 01:27 PM
VbCr is just a Carriage Return, which if you think about a typewriter a Carriage return would return the type head to the begging on the line. VbCrLf is a carriage return with a line feed, basically moving the carriage to the begging of the line and then one line down.
I don’t think that VbCr is ever used except in special cases, such as if your printing directly to a dot matrix printer.
If your trying to display a new line in the web page then you need to use the html tag <br> if your trying to store a new line in your database or text file or what ever then use the VbCrLf. But if your just going to store that information then later recall it a display it on the web page then it may be easier to just store it using the <br>, otherwise you will need to retrieve the information then use Replace() and find all the VbCrLf’s and replace them with <br>’s.
August 25th, 2003, 11:59 AM
here is the answer
I was googling this morning for "vbsript newline" and this was the first result and as i sighed closing the page - i realised newlines in windows and unix are real different and i forgot this fact - if you are coding in windows, newline is CR followed by LF. In the ASCII table of characters, a CR is a 13 and an LF is 10. So if you are scripting in VBS on windows you would want to do a vbCr and a vbLf
mystring = "here" & vbCr & vbLf
Wscript.echo mystring 'should show you a newline after here
hope that helps - go me go
PS: I registered just to post this reply - but i might come back later - i do scripting strictly to automate test environments - no web stuff for me
August 25th, 2003, 01:09 PM
p00mer, for future reference, vbCrLf is vbCr & vbLf.
Anyway, welcome to the community.
January 5th, 2007, 11:29 AM
To insert a new line in vbscript do this
[code] %> <br> <%[code]
the command vbCrLf insert a new line into a database, not into a webpage
i think this can help
it worked for me
January 5th, 2007, 03:41 PM
Please refrain from posting answers in threads that are several years old, specially ones that already have correct answers.
January 19th, 2009, 04:21 AM
Add New Line in VB script
Try this out:-
MyStr = "VBScript SecondLine"
MyStr=Split (MyStr," ")
Mynewstr= MyStr(0) & vbNewline 'This will create an newline
Mynewstr=Mynewstr & MyStr(1)
Comments on this post
January 19th, 2009, 06:05 PM
Hi bncs77 and welcome to these forums. It's easy to miss that a thread is old if you've googled your way here. Please don't bring ancient threads back to life, thanks. I'm locking this thread.
I've never been able to appreciate the sublime arrogance of folks who feel they were put on earth just to save other folks from themselves .." - Donald Hamilton