<p>Suppose I have a COM object which users can access via a call such as:</p>

<pre><code>Set s = CreateObject("Server")
</code></pre>

<p>What I'd like to be able to do is allow the user to specify an event handler for the object, like so:</p>

<pre><code>Function ServerEvent

   MsgBox "Event handled"

End Function

s.OnDoSomething = ServerEvent
</code></pre>

<p>Is this possible and, if so, how do I expose this in my type library in C++ (specifically BCB 2007)?</p>

I'm a little hazy on the details, but maybe the link below might help:
http://msdn.microsoft.com/en-us/library/ms974564.aspx
It looks like your server object needs to implement
```
IProvideClassInfo
```
and then you call
```
ConnectObject
```
in your VBScript code. See also:
http://blogs.msdn.com/ericlippert/archive/2005/02/15/373330.aspx