Imports System Imports uCalcSoftware Public Module Program Public Sub MyErrorHandler(ByVal h As Handle_uCalc) Dim uc As New uCalc(h) '// Check if the specific 'FloatInvalid' error was raised If uc.Error.Code = ErrorCode.FloatInvalid Then Console.WriteLine("Error: The calculation resulted in an invalid number (e.g., square root of a negative).") '// Stop further processing uc.Error.Response = ErrorHandlerResponse.Abort End If End Sub Public Sub Main() Dim uc As New uCalc() '// Register the custom error handler uc.Error.AddHandler(AddressOf MyErrorHandler) '// Tell uCalc to raise an error instead of returning 'nan' uc.Error.TrapOnInvalid = true '// This will now trigger our custom error handler's message uc.EvalStr("sqrt(-4)") End Sub End Module