Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim myHostArray() As Double = { 5, 10, 15, 20 } '// Pin the array Dim myHostArrayHandle = System.Runtime.InteropServices.GCHandle.Alloc(myHostArray, System.Runtime.InteropServices.GCHandleType.Pinned) '// Bind the uCalc variable to the pinned memory address uc.DefineVariable("MyArray[]", myHostArrayHandle.AddrOfPinnedObject()) '// The uCalc array values come from the host array Console.WriteLine(uc.Eval("MyArray[0]")) Console.WriteLine(uc.Eval("MyArray[1]")) Console.WriteLine(uc.Eval("MyArray[2]")) Console.WriteLine(uc.Eval("MyArray[3]")) Console.WriteLine("") '// Changing the uCalc array updates the pinned array uc.Eval("MyArray[0] = 10; MyArray[1] = 20; MyArray[2] = 30; MyArray[3] = 40; ") '// The changes the uCalc array are reflected in the host array Console.WriteLine(myHostArray(0)) Console.WriteLine(myHostArray(1)) Console.WriteLine(myHostArray(2)) Console.WriteLine(myHostArray(3)) Console.WriteLine("") '// One more round trip myHostArray(0) = 10 myHostArray(1) = 11 myHostArray(2) = 12 myHostArray(3) = 13 Console.WriteLine(uc.Eval("MyArray[0]")) Console.WriteLine(uc.Eval("MyArray[1]")) Console.WriteLine(uc.Eval("MyArray[2]")) Console.WriteLine(uc.Eval("MyArray[3]")) '// Don't forget to free the handle when you are completely done with the parser instance myHostArrayHandle.Free() End Sub End Module