To program Microsoft Agent from VBScript, use the HTML <SCRIPT> tags. To access the programming interface, use the name of control you assign in the <OBJECT> tag, followed by the subobject (if any), the name of the method or property, and any parameters or values supported by the method or property:
agent[.object].Method parameter, [parameter]
agent[.object].Property = value
For events, include the name of the control followed by the name of the event and any parameters:
Sub agent_event (ByVal parameter[,ByVal parameter])
statements…
End Sub
You can also specify an event handler using the <SCRIPT> tag's For…Event syntax:
<SCRIPT LANGUAGE=VBScript For=agent Event=event[(parameter[,parameter])]>
statements…
</SCRIPT>
Although Microsoft Internet Explorer supports this latter syntax, not all browsers do. For compatibility, use only the former syntax for events.
With VBScript 2.0, you can verify whether Microsoft Agent is installed by trying to create the object and checking to see if it exists. The following sample demonstrates how to check for the Agent control without triggering an auto-download of the control (as would happen if you included an <OBJECT> tag for the control on the page):
<!-- WARNING - This code requires VBScript 2.0.
It will always fail to detect the Agent control
in VbScript 1.x, because CreateObject doesn't work.
-->
<SCRIPT LANGUAGE=VBSCRIPT>
If HaveAgent() Then
'Microsoft Agent control was found.
document.write "<H2 align=center>Found</H2>"
Else
'Microsoft Agent control was not found.
document.write "<H2 align=center>Not Found</H2>"
End If
Function HaveAgent()
' This procedure attempts to create an Agent Control object.
' If it succeeds, it returns True.
' This means the control is available on the client.
' If it fails, it returns False.
' This means the control hasn't been installed on the client.
Dim agent
HaveAgent = False
On Error Resume Next
Set agent = CreateObject("Agent.Control.1")
HaveAgent = IsObject(agent)
End Function
</SCRIPT>
You can download VBScript 2.0 and obtain further information on VBScript at the Microsoft Download site and the Microsoft VBScript site.