Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// In C# and VB you should use "using". '// In C++ you can flag a uCalc object for '// auto-release with Owned(), or by setting '// the last parameter of the constructor to true. uc.IsDefault = true '// Set uc as the default uCalc object uCalc.DefaultInstance.DefineVariable("Value = 'Original uc object'") Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Outputs: Original uc object '// Use "using" so that the object is auto-released when it it goes out of scope Using uCalcTemp As New uCalc() uCalcTemp.IsDefault = true '// Set uCalcTemp as the default uCalc object uCalc.DefaultInstance.DefineVariable("Value = 'uCalcTemp object'") Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// uCalcTemp object End Using '// uCalcTemp goes out of scope here, and the default uCalc object reverts back to uc Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Original uc object If True Then Dim uCalcSticky As New uCalc() '// remains the default even after going out of scope uCalcSticky.IsDefault = true '// Set uCalcSticky as the default uCalc object uCalc.DefaultInstance.DefineVariable("Value = 'uCalcSticky object'") Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) '// Outputs: uCalcSticky object End If '// The uCalcSticky object itself goes out of scope here, but internally it remains the default uCalc object Console.WriteLine(uCalc.DefaultInstance.EvalStr("Value")) End Sub End Module