Imports System.IO Module _Debug Public debug As Boolean = True End Module Module _Log Public Const LOG_ERROR As Byte = 0 'Default Public Const LOG_DETAIL As Byte = 1 Public Sub Log(ByVal msg As String, Optional ByVal type As Byte = 0, Optional ByVal showToUser As Boolean = False) If Not Directory.Exists(My.MySettings.Default.logPath) Then Directory.CreateDirectory(My.MySettings.Default.logPath) End If Dim _fullPath As String = My.MySettings.Default.logPath & "\" & My.MySettings.Default.logFile Dim iLogFile As New FileInfo(_fullPath) If iLogFile.Exists Then If iLogFile.Length > (1024 * 10) Then iLogFile.Delete() iLogFile.Create() If Not iLogFile.Exists Then MsgBox("ERROR - Accessing Log File:" & _fullPath) Return End If End If Else iLogFile.Create() If Not iLogFile.Exists Then MsgBox("ERROR - Accessing Log File:" & _fullPath) Return End If End If Dim sLogFile As StreamWriter sLogFile = iLogFile.AppendText() Select Case type Case 0 If debug Then MsgBox("ERROR - " & msg) sLogFile.WriteLine("ERROR - " & msg) Else If showToUser Then MsgBox("ERROR - " & msg) End If sLogFile.WriteLine("ERROR - " & msg) End If Case 1 If showToUser Then MsgBox("DETAIL - " & msg) End If If debug Then sLogFile.WriteLine("DETAIL - " & msg) End If End Select sLogFile.Flush() sLogFile.Close() End Sub End Module