错误信息输出到TEXT中改良

上一篇 / 下一篇  2009-08-13 21:28:04 / 个人分类:散文

错误信息输出到TEXT中

On error resume next

datatable.GlobalSheet.DeleteParameter "num" '实际Global表中没有num这个字段,运行时会报错.
txtErrorReporter "d:\errors.txt",err.Number,err.Source,err.Description
Err.Clear   ' Clear the error.

Err.Raise 6   ' Raise an overflow error.
txtErrorReporter "d:\errors.txt",err.Number,err.Source,err.Description
Err.Clear   ' Clear the error.

Public Function txtErrorReporter (fileName,errNumber,errSource,errDescriptionl)

   
    Const ForReading = 1, ForWriting = 2, ForAppending = 8
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set errFile = fso.OpenTextFile(fileName, ForAppending, True)
    errFile.WriteLine("")
    errFile.WriteLine(" ---------------------------------------------------------")
    errFile.WriteLine(" Time:" & Cstr(Now))
    errFile.WriteLine(" Error Number:" & errNumber )
    errFile.WriteLine(" Error Source:" & errSource )
    errFile.WriteLine(" Error Description:" & errDescriptionl)
    errFile.Close

    Set errFile = nothing
    Set fso = nothing
End Function

TAG:

 

评分:0

我来说两句

Open Toolbar