Can you raise events in the 'class_initialize' section of a class module?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Can you raise events in the 'class_initialize' section of a class module?

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Can you raise events in the 'class_initialize' section of a class module?

    [Originally posted by Jonathan Jones]

    When I instantiate an object, I need to check a variable on one of my forms for the object to instantiate properly (I'm not using class persistance via the property bag at this point). Is it possible to raise an event inside the 'class_initialize' section of the class module that raises an event inside the calling form which in turn, calls the 'Property Let' property of the class? Wow - that was a mouthful.

    So I guess it would look like this:
    -------------------------------------------------
    clsTemp
    -------------------------------------------------
    Option Explicit

    Private m_varVariable as Variant
    Public Event GetVariable()

    Private Sub Class_Initialize()
    RaiseEvent GetVariable
    End Sub

    Public Property Let Variable(v_var as variant)
    m_varVariable = v_var
    End Property

    -------------------------------------------------
    frmMain
    -------------------------------------------------
    Private varVariable_to_Pass
    Private WithEvents objTemp as clsTemp

    Private Sub Form_Load()
    Set objTemp = New clsTemp
    End Sub

    Private Sub objTemp_GetVariable()
    objTemp.Variable(varVariable_to_Pass)
    End Sub

    Thanks for any input!

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Can you raise events in the 'class_initialize' section of a class module?

    [Originally posted by FreeVBCode.com]

    I don't see why your code shouldn't work, but the best way to find out is to try it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center