Beginning MS Agent: Part 3
Now that we have added the command to the character, the user can click on the menu item or speak a word or phrase to call the command. Now how do we use that to do something useful? We use the Agent1_Command procedure. The following procedure corresponds to the command we added above.
Private Sub Agent1_Command(ByVal UserInput as Object)Select Case UserInput.Name Case "ACO" Agent1.PropertySheet.Visible = TrueEnd SelectEnd Sub
As you can see, we have added the functionality to our command, "ACO". When the user clicks on the menu item or says one of the voice commands, the Advanced Character Options property sheet is shown. "UserInput" corresponds to the user either selecting the menu option or saying the voice command. The ".name" property is then updated with the name of the command the user called. Here is where naming your command is important. A simple Select structure allows us to easily add something for our command to do.
Page 3 of 6