i want to control the error message when calling f

2019-03-03 11:13发布

问题:

i want to customize my own error box and message when an error occur in calling a function .

enter image description here

i try to use try catch an exception but not doing anything

    Try
            L = objGeoFlowDLL.GFCalc_Main(nInputs, nOutputs, sngInputs, sngOutputs)

        Catch ex As Exception
            MessageBox.Show(ex.Message)
            '  Me.Close()
        Finally

        End Try

回答1:

Try
  L = objGeoFlowDLL.GFCalc_Main(nInputs, nOutputs, sngInputs, sngOutputs)
Catch ex As DivideByZeroException
  MessageBox.Show("Custom message to be shown when something is divided by zero.")
Catch ex2 As Exception
  MessageBox.Show("Custom message to be shown when any other error occurs.")
End Try