Thursday, April 7, 2011

How Script to write in the file and read using loop?

"Also to get the version detail of vbscript."

Dim filesys, text, readfile, contents


set filesys = CreateObject("Scripting.FileSystemObject")
Set text = filesys.CreateTextFile("c:\test.txt")


text.Write "Find the last character in the text file"
text.Write " '
text.Write "Find the last character in the text fil"
text.Close


Set readfile = filesys.OpenTextFile("c:\somefile2.txt", 1, false)
Do while readfile.AtEndOfLine <> true 'Condition to get end letter of first line'


'Do while readfile.AtEndOfStream <> true 'Condition to get end letter of file'
contents = readfile.Read(1)
'WScript.Echo contents 'Print all the letter for file'
Loop
readfile.close


'Response.Write "The last character in the text file is '" & contents & "."
WScript.Echo "The last character in the text file is '" & contents & "."
WScript.Echo ScriptEngine
WScript.Echo ScriptEngineBuildVersion
WScript.Echo ScriptEngineMajorVersion
WScript.Echo ScriptEngineMinorVersion
WScript.Echo Second(Time)
WScript.Echo Tan(55.0)

No comments:

Post a Comment