PDA

Click to See Complete Forum and Search --> : active X Controls, Classes & events


visualAd
Aug 29th, 2002, 03:53 PM
I have created an active x control which contains four classes. I have basically created a control which accesses the registry, the classes being: key, keys, value and values. I am looking to use this control with the windows script host and would like to raise an event in one of the classes and allow the client code to respond to this.

I have tried the following.
1) Creating istances of the class using the WithEvents statement. However the user control complains that it cannot be done inside a procedure.


Public Function getKey(ByVal strKeyName As String) As Key
Dim WithEvents returnKey As Key

Set returnKey = New Key
......


2) I have also tried declaring a global variable WithEvents and assigning a new object variable to that global variable.

Does anyone know a way of making an event raised in a class visible to a WSH Script??

amitabh
Aug 30th, 2002, 03:56 PM
You can only use WithEvents keyword with a Private qualifier.

Private WithEvents ........


Why don't you smply use the Raise Event method?

visualAd
Aug 31st, 2002, 01:47 AM
Doesn't the class need to be declared Eith Events for this to be recognised.

amitabh
Aug 31st, 2002, 02:41 AM
Yes the Withevents for the class needs to be declared to get a response from Raise Event mehod, but it has to be inside a class module or a form module, It will not work on standard modules, and it has to be Private.