Initializing the MSAgent control is fairly straightforward, as shown in Listing 14.2. All I need to do is use the Characters.Load method to load the Agent information into the Characters collection. This will let me choose any of these characters later in the program.
Listing 14.2: Form_Load Event in Hello Jill
Private Sub Form_Load()
Agent1.Characters.Load “Genie”, AgentPath & “Genie.acs”
Agent1.Characters.Load “Merlin”, AgentPath & “MerlinSfx.acs”
Agent1.Characters.Load “Robby”, AgentPath & “Robby.acs”
Combo1.AddItem “Genie”
Combo1.AddItem “Merlin”
Combo1.AddItem “Robby”
Combo1.Text = “Genie”
End Sub
To load a character, I need to specify the name of the Agent and the name of file where the Agent’s information is saved. Note that I used MerlinSfx rather than Merlin because I’m curious about the sound effects. I then initialized the Combo1 control with a list of the Agents available in the program so I can let the users choose which Agent they would like to see and hear.