我想在调用函数返回错误时控制错误消息

时间:2018-11-05 11:57:54

标签: vb.net error-handling

当调用函数发生错误时,我想自定义自己的错误框和消息。

enter image description here

我尝试使用try捕获异常,但不执行任何操作

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

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

        End Try

1 个答案:

答案 0 :(得分:0)

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