How would i save text in a VBScript code?

so far i can create a text file with this code :


set objFile= CreateObject ("Scripting.FileSystemObject")
Set textfile = objFile.CreateTextFile("Results.txt")

but i dont know how i would save text to that file. any help?

7 answers
sort by: active | newest | oldest
Dec 16, 2009. 9:57 AMg-one says:
Thats not a problem. WriteLine or Write is what you need. The question is where does the text come from?
Dec 16, 2009. 12:42 PMg-one says:
Try this:

Dim nm, em, FSO, oFile

nm = InputBox("Please enter the 1st line:", "Value for ""nm""")
em = InputBox("Please enter the 2nd line:", "Value for ""em""")

Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFile = FSO.OpenTextFile("Results.txt", 2, True)
oFile.Write(nm & vbCrLf & em)
oFile.Close

Set oFile = Nothing
Set FSO = Nothing

Dec 16, 2009. 2:16 PMg-one says:
That is the VB - constant for the line break.

Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!