Structuere with WithEvents members
-
Hi all, In VB2005 I want to create an structure that some of its members should be declared with the WithEvents statement as they generate events that I'd like to handle. The compiler doesn't permit to declare members of an strcuture with WithEvents. Is there any way to do it? thanks in advance, Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
-
Hi all, In VB2005 I want to create an structure that some of its members should be declared with the WithEvents statement as they generate events that I'd like to handle. The compiler doesn't permit to declare members of an strcuture with WithEvents. Is there any way to do it? thanks in advance, Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
You'll have to use a class instead. Here is a link defining the differences. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vaconStructuresAndClasses.asp[^] Although a structure's methods can handle events the method must be shared and the handler must be added using Addhandler. To quote the info in the link: "A structure procedure can handle events only if it is a Shared (Visual Basic) Sub procedure, and only by means of the AddHandler Statement; any class procedure can handle events, using either the Handles keyword or the AddHandler statement. For more information, see Events and Event Handlers."