'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
LogError(Error.Message)
Return True
End Sub
Sub LogError(strErrorMsg As String)
Dim str As String
Dim strCurrentDateTime As String
Dim strDateFormat As String
'keep the current date format
strDateFormat = DateTime.DateFormat
DateTime.DateFormat = "EEE, d/MMM/yyyy HH:mm:ss"
strCurrentDateTime = DateTime.Date(DateTime.Now)
str = File.ReadString(strAppDir, "AppLog.txt")
If str.Length = 0 Then
File.WriteString(strAppDir, "AppLog.txt", strCurrentDateTime & CRLF & strErrorMsg)
Else
File.WriteString(strAppDir, "AppLog.txt", str & CRLF & CRLF & strCurrentDateTime & CRLF & strErrorMsg)
End If
DateTime.DateFormat = strDateFormat
End Sub