Handling Errors in the VBA Compiler
Runtime errors can occur when your compiled VBA code is executed. While standard VBA uses the On Error statement for error handling, the XLS Padlock VBA compiler uses a Try...Except block.
When an error occurs within the Try block (or any procedure it calls), the compiler will immediately jump to the Except block for handling.
Syntax
Section titled “Syntax”Try ' ... Code to execute ...Except ' ... Code to run if an exception occurs ...EndCode Example
Section titled “Code Example”NumberStr = ""if InputQuery("Input", "Type an integer from 1 to 7", NumberStr) then try Number = StrToFloat(NumberStr) except raise("Not a valid number") end
select case Number case 1 ShowMessage("One") case 1 + 1 ShowMessage("Two") case 4.5 / 1.5 ShowMessage("Three") case 2 * 2 ShowMessage("Four") case Length("xxxxx") ShowMessage("Five") case 3 + 3, 3 + 4 ShowMessage("Six or Seven") case else ShowMessage("You did not type an integer from 1 to 7") end selectend if