Module Module1

    Sub Main()

        Dim Eng As CaoEngine
        Dim Ws As CaoWorkspace
        Dim Ctrl As CaoController
        Dim Var As CaoVariable

        ' Create a CaoEngine
        Eng = New CaoEngine

        ' Get the default workespace
        Ws = Eng.Workspaces().Item(0)

        ' Create a CaoController
        Ctrl = Ws.AddController("RC1", "CaoProv.Dummy", )

        ' Create a CaoVariable
        Var = Ctrl.AddVariable("S11")

        ' Put a value
        Console.WriteLine("Input data :")
        Var.Value = Console.ReadLine()

        ' Get the value
        Console.WriteLine("Output data : " & Var.Value)
        Console.WriteLine("Press any key.")
        Console.Read()

        ' Release Com objects
        SetNothing(Var)
        Ws.Controllers.Remove(Ctrl.Index)
        SetNothing(Ctrl)
        SetNothing(Ws)
        SetNothing(Eng)

    End Sub

    Sub SetNothing(ByRef obj As Object)

        If (obj IsNot Nothing) And Marshal.IsComObject(obj) Then
            Marshal.ReleaseComObject(obj)
            obj = Nothing
        End If

    End Sub

End Module
