GT500Shlby
Newcomer
I am having a problem with an ErrorHandler
With the Goto and Resumes. I want to call a Goto and then resume where I left off.
With the Goto and Resumes. I want to call a Goto and then resume where I left off.
Code:
Public Function errHandler(ByVal intErrFlag As Integer, Optional ByVal strErrString As String = "") As Integer
Dim strErrorMessage As String
Dim msgbxStyle As MessageBoxOptions
Dim strErrorTitle As String
Dim response As MsgBoxResult
Select Case intErrFlag
Case 1
strErrorMessage = "Configuration and Data Files not found! Would you like to browse for them?"
msgbxStyle = MsgBoxStyle.YesNo
strErrorTitle = "Config File Error..."
GoTo showbox
Resume
If response = MsgBoxResult.Yes Then
With OpenFileDialog1
.InitialDirectory = strConfigFile
.Filter = "PD Rating Configuration (*.ini)|*.ini"
.ShowDialog()
strConfigFile = .FileName()
End With
Return 1
Else
strErrorMessage = "Cannot Recover from errors... Quitting."
msgbxStyle = MsgBoxStyle.OKOnly
strErrorTitle = "Quitting..."
End
End If
Exit Function
Case 2
strErrorMessage = "File Read Error: " & strErrString
msgbxStyle = MsgBoxStyle.OKOnly
strErrorTitle = "Error Reading File..."
GoTo showbox
Resume
writErrorLog(2, strErrorMessage)
Err.Clear()
Exit Function
Case 3
strErrorMessage = "File Write Error: " & strErrString
msgbxStyle = MsgBoxStyle.OKOnly
strErrorTitle = "Error Writing File..."
GoTo showbox
Resume
writErrorLog(2, strErrorMessage)
Err.Clear()
Exit Function
End Select
Exit Function
showbox:
Beep()
response = MsgBox(strErrorMessage, msgbxStyle, strErrorTitle)
'Resume Next
End Function