Solved

Problem in using Microsoft Agent in VB

Posted on 2001-06-26
7
250 Views
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
code:

Private Sub mnuViewAgent_Click()
   mnuViewAgent.Checked = Not mnuViewAgent.Checked
   
   If mnuViewAgent.Checked = True Then
      MyAgent.Show
   Else
      MyAgent.Hide
   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"
           mnuViewAgent_Click
   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
         MyAgent.Show
      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
         DoEvents
      Loop
      If mnuViewAgent.Checked = False Then
         MyAgent.Hide
      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).

Thanks.
0
Comment
Question by:Bhowal
  • 4
  • 2
7 Comments
 
LVL 8

Accepted Solution

by:
glass_cookie earned 100 total points
ID: 6228606
Hi!

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?
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6228643
Hey Bhowel,

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

Author Comment

by:Bhowal
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", _
       "C:\WINDOWS\MSAGENT\CHARS\Genie.acs"
    Set MyAgent = Agent1.Characters("Genie")
In case you have not yet tried Microsoft Agent, you can down load the same from following site:
http://www.microsoft.com/intdev/agent/agent-f.htm.   And add Microsoft Agent Control in Project>Components                  It's fun.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 8

Expert Comment

by:glass_cookie
ID: 6233662
HI!

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

That's it!

glass cookie : )
0
 
LVL 8

Expert Comment

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

Author Comment

by:Bhowal
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:

http://msdn.microsoft.com/workshop/imedia/agent/agentdl.asp
 
0
 
LVL 8

Expert Comment

by:glass_cookie
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 : )

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now