J
jcrouse
I am using the following code to trap errors in a sub routine:
Try
Executable code
Catch ex As Exception
Dim strInputE As String = Application.StartupPath & "\Error.txt"
Dim srE As StreamWriter = File.AppendText(strInputE)
srE.WriteLine(vbCr)
srE.WriteLine(vbCr)
srE.WriteLine(DateTime.Now)
srE.WriteLine("------------------")
srE.WriteLine(ex.ToString)
srE.Close()
MsgBox("An Error has occurred. Please check the file " &
Application.StartupPath & "\Error.txt for details.", MsgBoxStyle.Critical,
CPViewer")
Exit Sub
Finally
cleanup code
End Try
I tested this and it seems to work. However, I don't really want to place it
in probably 300 subs in 12 different forms. What are my options here?
Thank you,
John
Try
Executable code
Catch ex As Exception
Dim strInputE As String = Application.StartupPath & "\Error.txt"
Dim srE As StreamWriter = File.AppendText(strInputE)
srE.WriteLine(vbCr)
srE.WriteLine(vbCr)
srE.WriteLine(DateTime.Now)
srE.WriteLine("------------------")
srE.WriteLine(ex.ToString)
srE.Close()
MsgBox("An Error has occurred. Please check the file " &
Application.StartupPath & "\Error.txt for details.", MsgBoxStyle.Critical,
CPViewer")
Exit Sub
Finally
cleanup code
End Try
I tested this and it seems to work. However, I don't really want to place it
in probably 300 subs in 12 different forms. What are my options here?
Thank you,
John