2013-07-09 164 views
1

我想在try catch中包装简单的语句。问题是我能够找到的所有示例都会讨论预定义的错误。尝试捕捉语句realBasic

我需要一个通用的错误,类似于C#中的try/catch。

回答

2

对于泛型尝试捕捉你可以这样做:

try 

    ...put some code here 

catch 

    ...do something for ANY exception here. 

finally 

    ...code here that runs IF an exception occurs 

end try 

闭锁段具有可选参数捕捉某些类型的错误(你见过的例子)。第一段给出的定义为http://docs.xojo.com/index.php/Try

Try 

// Your code 

Catch [ErrorParameter] [As ErrorType] 

//exception handlers 

[ Finally ] 

//code that executes even if runtime exceptions were raised 

End [Try] 
+0

这样做就可以了! – EnterpriseXL