Imports System
Imports uCalcSoftware
Public Module Program
   
   Public Sub MyHandler(ByVal h As Handle_uCalc)
      Dim uc As New uCalc(h)
      '// Retrieve the error code as an integer for display
      Dim code As Integer = uc.Error.Code
      Console.WriteLine($"Caught Error Code: {code}")
      
      '// Compare the error code against the ErrorCode enum for logic
      If uc.Error.Code = ErrorCode.Syntax_Error Then
         Console.WriteLine("This was a syntax error.")
      End If
   End Sub
   
   Public Sub Main()
      Dim uc As New uCalc()
      '// Register the error handler
      uc.Error.AddHandler(AddressOf MyHandler)
      
      '// Intentionally cause a syntax error, which will trigger the handler
      Console.WriteLine(uc.EvalStr("5 *"))
   End Sub
End Module