Problems with linebreaks(VBScript)

Hello!

I'm a beginner in VBScript and here is a piece of code I'm struggling with:

dim filesys, mytext

set filesys = CreateObject("Scripting.FileSystemObject")
set mytext = filesys.CreateTextFile("C:myfolderonefile.txt")
mytext.Write "Hello, " & CHR(10) & "world!"
mytext.close

And the problem is: this CHR(10) does not break the line.

Are there any other commands I should use instead?

Thanks.

Comments

  • : Hello!
    :
    : I'm a beginner in VBScript and here is a piece of code I'm
    : struggling with:
    :
    : dim filesys, mytext
    :
    : set filesys = CreateObject("Scripting.FileSystemObject")
    : set mytext = filesys.CreateTextFile("C:myfolderonefile.txt")
    : mytext.Write "Hello, " & CHR(10) & "world!"
    : mytext.close
    :
    : And the problem is: this CHR(10) does not break the line.
    :
    : Are there any other commands I should use instead?
    :
    : Thanks.
    :
    :
    In Windows line endings are represented by 2 characters: newline (10) followed by carriage return (13). Either of them doesn't create a line ending, only both.
  • : : Hello!
    : :
    : : I'm a beginner in VBScript and here is a piece of code I'm
    : : struggling with:
    : :
    : : dim filesys, mytext
    : :
    : : set filesys = CreateObject("Scripting.FileSystemObject")
    : : set mytext = filesys.CreateTextFile("C:myfolderonefile.txt")
    : : mytext.Write "Hello, " & CHR(10) & "world!"
    : : mytext.close
    : :
    : : And the problem is: this CHR(10) does not break the line.
    : :
    : : Are there any other commands I should use instead?
    : :
    : : Thanks.
    : :
    : :
    : In Windows line endings are represented by 2 characters: newline
    : (10) followed by carriage return (13). Either of them doesn't create
    : a line ending, only both.

    Yes, now I get it.
    CHR(13)&CHR(10)
    Now it works. Thanks a lot!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories