Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Problem in using Microsoft Agent in VB

Posted on 2001-06-26
Medium Priority
Last Modified: 2008-02-01
I have written an application in VB 5 where Microsoft Agent (Genie) is used.
I am using a menu and toolbur button to show or hide the agent with following

Private Sub mnuViewAgent_Click()
   mnuViewAgent.Checked = Not mnuViewAgent.Checked
   If mnuViewAgent.Checked = True Then
   End If
End Sub

Private Sub tbToolBar_ButtonClick(ByVal Button As ComctlLib.Button)
   Select Case Button.Key

      Case "...."
                  ' Code for other toolbar button goes here    
      Case "Agent"
   End Select
End Sub

I am also using a command button for the agent to speak with following code:

Private Sub cmdSpeak_Click()
      If mnuViewAgent.Checked = False Then
      End If
      Set MyRequest = MyAgent.Speak(strSpeak) ' Some string is set in other part
      'To prevent the application from continuing
      'until the agent completes its task
      Do Until MyRequest.Status = 0
      If mnuViewAgent.Checked = False Then
      End If
End Sub

Problem is the application is showing some erratic behaviour (see
sequence of operation):
Agent is not shown (not appearing),
mnuViewAgent or corresponding toolbar button is clicked,
mnuViewAgent is checked and Agent is shown,
some other actions (not related with mnuViewAgent, corresponding toolbar buttonm
and cmdSpeak) are done,
munViewAgent is found to be unchecked, though Agent is still shown (visible).

Question by:Bhowal
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2

Accepted Solution

glass_cookie earned 400 total points
ID: 6228606

This is what you may want to do in the event of having some funny problems:

- After each case in your toolbar event, add the line:
Exit Sub

- After this line:
mnuViewAgent.Checked = Not mnuViewAgent.Checked

Add a message box to test the value of mnuViewAgent.Checked and see if it works fine.

- Make sure that you do not have any code in the Form_Load event of the form, MyAgent which may cause the for to 'not showing'. Make sure also that the event does not change the value of mnuViewAgent

- For your cases:
Case "Agent"

Make sure that there isn't any repetition of it earlier on or it would execute the earlier case and ignore the later case.

- Make sure that you didn't use any timers to call any _click event of any controls.

That's it and good luck!

glass cookie ; )

PS. By the way, is MyAgent a control or a form?  If it's a control, shouldn't there be a 'Visible' property instead?

Expert Comment

ID: 6228643
Hey Bhowel,

I have develolped with MS Agents before... but I am not sure what you are trying to accomplish...  

Author Comment

ID: 6231821
Thanks. I found the bug from your hint. Actually I had some unwanted code in Form_Paint event which was unchecking the mnuViewAgent.

MyAgent is an ActiveX control. I am using this code
In General section:
Dim MyAgent As IAgentCtlCharacter

In Form_Load:
'Load character data into the application
    Agent1.Characters.Load "Genie", _
    Set MyAgent = Agent1.Characters("Genie")
In case you have not yet tried Microsoft Agent, you can down load the same from following site:   And add Microsoft Agent Control in Project>Components                  It's fun.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 6233662

Thanks for the link.  I'm gonna try out agent later : )

That's it!

glass cookie : )

Expert Comment

ID: 6233664
Ooo... it seems like a dead link.  It's OK though : )

Author Comment

ID: 6235087
Glass cookie,
       I am sorry. Yes,  it's a dead link. However, it still gave me further links to connect to Microsoft Agent download site.
If you are still not through you may try the following link:

Expert Comment

ID: 6247321
Oops, another dead link, but it's OK.  Thanks for your time.  I'll be able to look for it when I'm free.  Don't trouble yourself anymore : )

That's it!

glass cookie : )


Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question