How to use WithEvents keyword with global variable?
问题 I am trying to declare a variable in a VB6 module as follows: Public WithEvents MyObject As MyClass The help files say that WithEvents can only be used in class modules. Why can't it be used in .bas modules? The legacy code I am working has an object declared globally in a module. I want to add WithEvents to this declaration but I need to keep the object global because many other forms etc refer to the object. How can I achieve this with minimal disruption to the code? 回答1: Write a class that