Writing your own COM component using VB.NET
This article takes you through the steps of creating and writing your own COM component in VB.NET that can be called from Analytica. You can use your component to compute something and return the result, to interface with other applications, or to interact with the user.
Note: Calling a COM component requires Analytica Enterprise release 4.6 or higher.
To follow this example, you will also need to have
- Microsoft Visual Studio with VB (I am using Visual Studio 2013)
- .NET Framework 4.0 or higher (I am using .NET 4.5).
Using the component
In this example, we will create a component that accepts text and speaks it using a voice synthesizer. You would use this from your Analytica Model as follows.
- Variable Speaker :=
COMCreateObject("AnaVoice.Speaker")
- Button RunIt
- OnClick:
LongComputation ; Speaker->Say("The simulation has finished")
- OnClick:
Creating the project
Steps:
- Start Visual Studio.
- To enable Visual Studio to register your component for you, you should launch it as Administrator. Right-click on the Visual Studio icon and select Run as administrator.
- Select New Project...
- Select Visual Basic + Windows + Class Library, and name your project (I've named this one
AnaVoice
). - From the menus, select Project / AnaVoice Properties / Compile.
- If you'll be using Analytica 64-bit, then from the menus select Build / Configuration Manager....
Defining and registering a class
Implementing a Method
See Also
Comments
Enable comment auto-refresher