VBA Code Protection > Handling errors in VBA compiler
Runtime errors can occur when your compiled VBA code is executed. In VBA, you use the VBA “On Error” statement for error handling. This statement performs some action when an error occurs during runtime.
XLS Padlock’s VBA compiler does not rely on the “On Error” event but provides a simply construct for wrapping code with error handling. When an error occurs in the wrapped code (or anything it calls), the code will jump to the error handling part of the wrapping code:
The code we want to execute
This code gets executed if an exception occurs in the above block
An error which is not handled by your code will be displayed by the VBA compiler at runtime, unless you disable this option.
if InputQuery("Input", "Type an integer number from 1 to 7", NumberStr) then
raise("Not a valid number")
select case Number
case 3+3, 3+4
ShowMessage("Six or Seven")
ShowMessage("You did not type an integer from 1 to 5")
Copyright © 2021 G.D.G. Software