Archives‎ > ‎MSAGENTS‎ > ‎


Part 1 - Loading the Microsoft Agent Control

The easiest way to load the agent control is to select it from the controls menu in VB and just drop it on your form.


Alternatively you can add a reference to the Microsoft Agent Control 2.0 from the References menu item in Visual Basic and create an object for the control at runtime like this:

     Private WithEvents MSAgent As Agent
    Set MSAgent = New Agent


For the purposes of this text we will assume the name of the Agent Control is called "MSAgent".



Part 2 - Loading a Character

A Character file defines what your agent will look like, and all the character animations are stored there. Before you can begin programming for MS Agent you need to specify what character file to open.

     ‘Create a Character Object
     Private Merlin As IAgentCtlCharacterEx

     ‘Load the Default Character by not supplying
     ‘an ACS file
     MSAgent.Characters.Load "Merlin", _ 

     ‘Set the Merlin object to our new character.
     Set Merlin = MSAgent.Characters("Merlin")


Microsoft Agent 2.0 has the ability to allow the user to enter in a default character to use with programs. If you want to load the default character the code looks just about the same.

Instead of doing this:

     MSAgent.Characters.Load "Merlin", “c:\windows\msagent\chars\merlin.acs”


We just need to leave out the path and the default will be used, like this:

     MSAgent.Characters.Load "DefaultCharacter"


To show your character on the screen do the following:



You can also hide your character by doing this: