Results 1 to 12 of 12

Thread: WithEvents

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Question WithEvents

    If your app can create many instances of a class module, which has public events, then how to you catch it's events after it's been created. Say you change data in one of the 10 instances of the class modules, how do you catch it's Dirty event in the main app?
    If the class module is in a collection the event is ignored and if it's in an array then you can't decalre them WITHEVENTS

    Anyone?

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You'll have to use callbacks, either from the individual classes to the collection or just from the class to some form of notify class.

  3. #3

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Here is an example which should explain it. Some of the properties are Friend instead of public but since the classes are in the project instead of a dll they show up anyway. Otherwise the collection and class wouldn't seem to be any different then normal.

  5. #5

  6. #6
    gaffa
    Guest
    Make the class call a friend method in the collection object it belongs to, passing itself in as a parameter, then make the collection raise the event out to the big wide world, passing out hte class that caled the frind method

    - gaffa

  7. #7

  8. #8

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking If it's not red then it must be a teapot...

    To do this you need to have the Parent Collection class as a varible in each Object Class...doesn't this scoff memory like crazy???

  9. #9
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    No because you are using SET (without new) so you really aren't creating another collection you are referencing the same one over again. If we passed it ByVal then we'd have some hefty memory.

  10. #10

  11. #11
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339


    You know I think I make a point to read your threads just for the crazy caption dealies.

  12. #12

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking On we go to another BBQ. It's in the North Pole...SOD THAT! Set fire to your house.

    Thank you.
    I try my best to lighten the atmosphere up while people are at work

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