loading

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?

sort by: active | newest | oldest
g-one7 years ago
Thats not a problem. WriteLine or Write is what you need. The question is where does the text come from?
animan1 (author)  g-one7 years ago
well i comes from an inputbox and then changes to a variable "nm" and "em" but i could combine the variables to make one
g-one animan17 years ago
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

animan1 (author)  g-one7 years ago
vbCrLf??
animan1 (author)  animan17 years ago
i just used wright twice it works though thnk
g-one animan17 years ago
That is the VB - constant for the line break.
animan1 (author)  g-one7 years ago
nvm i got it