#1
  1. No Profile Picture
    Demonic Swordsman DGQB
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Apr 2003
    Posts
    1,043
    Rep Power
    83

    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!

    HELP!
  2. #2
  3. No Profile Picture
    Demonic Swordsman DGQB
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Apr 2003
    Posts
    1,043
    Rep Power
    83
    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.
  4. #3
  5. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    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.
  6. #4
  7. No Profile Picture
    Overly white
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Location
    Fresno, CA
    Posts
    83
    Rep Power
    12
    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.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    1
    Rep Power
    0

    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

    something like

    'example

    dim mystring

    mystring = "here" & vbCr & vbLf

    Wscript.echo mystring 'should show you a newline after here

    'end example

    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
  10. #6
  11. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    p00mer, for future reference, vbCrLf is vbCr & vbLf.

    Anyway, welcome to the community.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2007
    Posts
    1
    Rep Power
    0
    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

  14. #8
  15. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    Please refrain from posting answers in threads that are several years old, specially ones that already have correct answers.

    Thank you.
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2009
    Posts
    1
    Rep Power
    0

    Add New Line in VB script


    Try this out:-

    Dim MyStr

    MyStr = "VBScript SecondLine"

    MyStr=Split (MyStr," ")

    Mynewstr= MyStr(0) & vbNewline 'This will create an newline

    Mynewstr=Mynewstr & MyStr(1)

    MsgBox Mynewstr

    Comments on this post

    • Ronster disagrees : Hey moke. The original question was posed almost 6 years ago. You really think you're helping him out? PLEASE do not resurrect OLD threads!
  18. #10
  19. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,428
    Rep Power
    4539
    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.
    ======
    Doug G
    ======
    The man who doesn't read good books has no advantage over the man who can't read them.
    --Mark Twain

IMN logo majestic logo threadwatch logo seochat tools logo