skip navigation

www.Hilands.com


Content:: VBS - Write Log Function

VBS - Write Log

You can add the function to your code and use it with a simple if statement
strTextToLog = NOW & " ""Something to log""" & vbcrlf
strLogFile = "logfile.log"
boolStat = Logger (strLogFile, strTextToLog)
View the function below
'###############################################################################
'# Logger                                                                      #
'#    write log file Function                                                  #
'#    Takes Input of file name then log text                                   #
'###############################################################################
Function Logger (strFile, strText)
	Set refFSO = CreateObject("Scripting.FileSystemObject")
	if refFSO.FileExists(strFile) then
		set refFile = refFSO.OpenTextFile(strFile, 8) ' 8 for append
	else
		set refFile = refFSO.CreateTextFile(strFile, TRUE)
	end if
	refFile.Write(strText)
	refFile.Close
	Set refFile = nothing
	Logger = true
End Function
writelog.func.inc.zip
download Download 405 bytes
MD5 - 38e239ff2a2ffd3082a78d5413e9373d *writelog.func.inc.zip
Last Modified: 2009-10-20