Writing your own COM component using VB.NET

Revision as of 00:06, 9 May 2015 by Lchrisman (talk | contribs) (Created page with "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 some...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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")

Creating the project

Steps:

  1. 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.
  2. Select New Project...
  3. Select Visual Basic + Windows + Class Library, and name your project (I've named this one AnaVoice).
    VB COM New Project.png
  4. From the menus, select Project / AnaVoice Properties / Compile.
    Scroll down and check Register for COM interop
    VB COM Register for COM interop.png
  5. If you'll be using Analytica 64-bit, then from the menus select Build / Configuration Manager....
    In the table, change Any CPU to <New...>. New platform should say x64. Press [OK].
    VB COM Configuration Manager.png


Defining and registering a class

Implementing a Method

See Also

Comments


You are not allowed to post comments.