5053Views7Replies

Author Options:

How would i save text in a VBScript code? Answered

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?

Tags:vbs

7 Replies

user
g-oneBest Answer (author)2009-12-16

Thats not a problem. WriteLine or Write is what you need. The question is where does the text come from?

Select as Best AnswerUndo Best Answer

user
animan1 (author)g-one2009-12-16

well i comes from an inputbox and then changes to a variable "nm" and "em" but i could combine the variables to make one

Select as Best AnswerUndo Best Answer

user
g-one (author)animan12009-12-16

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

Select as Best AnswerUndo Best Answer

user
animan1 (author)animan12009-12-16

i just used wright twice it works though thnk

Select as Best AnswerUndo Best Answer

user
g-one (author)animan12009-12-16

That is the VB - constant for the line break.

Select as Best AnswerUndo Best Answer