Results 1 to 4 of 4

Thread: active X Controls, Classes & events

  1. #1

    Thread Starter
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    active X Controls, Classes & events

    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.

    Code:
    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??

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    You can only use WithEvents keyword with a Private qualifier.
    VB Code:
    1. Private WithEvents ........

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

  3. #3

    Thread Starter
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Doesn't the class need to be declared Eith Events for this to be recognised.

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width