Imports System Imports uCalcSoftware Public Module Program Public Sub CustomIIf(ByVal cb As uCalc.Callback) Dim condition As Boolean = cb.ArgBool(1) Dim truePart = cb.ArgExpr(2) Dim falsePart = cb.ArgExpr(3) If condition Then cb.Return(truePart.Evaluate()) Else cb.Return(falsePart.Evaluate()) End If End Sub Public Sub Main() Dim uc As New uCalc() uc.DefineFunction("MyIIf(condition As Bool, ByExpr thenExpr, ByExpr elseExpr)", AddressOf CustomIIf) '// The 'else' branch contains a division by zero, but it should NOT be evaluated '// because the condition (1 < 2) is true. Dim result = uc.Eval("MyIIf(1 < 2, 100, 1/0)") Console.Write("Result 1: ") Console.WriteLine(result) '// Now test the false branch. The 'then' branch with the error is skipped. result = uc.Eval("MyIIf(1 > 2, 1/0, 200)") Console.Write("Result 2: ") Console.WriteLine(result) End Sub End Module