QTP 新建日志

'    Const Reading=1,Writing=2,Appending=8
'    Set Fso=CreateObject("Scripting.FileSystemObject")
'    Dim txtPath
'    a=DATE()
'    Datetime = date
'    Parameter = Array("yyyy","m","d")
'    For Each P In Parameter
'        Temp = DatePart(P,Datetime)
'        If Len(Temp) = 1 Then
'            Temp = "0"&Temp
'        End If
'        strTime = strTime & Temp
'    Next
'    c = strTime
'    MsgBox c
'    txtPath="E:\Log\"+c+".txt"
'    msgbox txtPath
'    If Fso.FileExists(txtPath) then
'        Set logFile=Fso.OpenTextFile(txtPath,8,true)
'        logFile.WriteLine(words)
                        
'    else
'        Set logFile=Fso.CreateTextFile(txtPath,2,true)
'        logFile.WriteLine(words)
'    End if
        
'    logFile.close
'    Set logFile=Nothing
'    Set Fso=Nothing    
'End Function

Public Function WritLog(words)
    Dim Fso
    Const Reading=1,Writing=2,Appending=8
    Set Fso=CreateObject("Scripting.FileSystemObject")
    Dim txtPath
'    msgbox a    
    c=FormatDateTime(date,1)
'    msgbox c
    txtPath="E:\Log\"+c+".txt"
'    msgbox txtPath
    If Fso.FileExists(txtPath) then
        Set logFile=Fso.OpenTextFile (txtPath,8,false)
        logFile.WriteLine(words)                        
    else
        Set logFile=Fso.CreateTextFile(txtPath,2,false)
        logFile.WriteLine(words)
    End if        
    logFile.close
    Set logFile=Nothing
    Set Fso=Nothing    
End Function

posted @ 2014-01-20 11:06  芯树  阅读(226)  评论(0编辑  收藏  举报