Tuesday, October 18, 2005 6:39 AM
So it has been posted previously that Structures were very much like Classes in the .NET framework with some very subtle differences.
While going over the material on structures in my class last night one of my better students that comes from a Java background asked a very interesting question. “If structures are so close to classes then can they handle events?”
Come to find out you can declare an event in a structure just as you can declare a Sub, Functions, Properties, and Constructors. But when I tried to declare a variable in my code as the type of structure “WithEvents”, the compiler seemed to have a problem with it. Also, it seems that if you were forgo the “WithEvents” declaration then you are not able to attach to the event with a handler.
So it seems that I was able to create the event, but not actually attach to it to do anything useful.
Now, I know that most of my recent experience is in C# where things don't seem to be as complicated and wordy as VB.NET, but I am sure that could have not typed in a step or missed some keyword. So if there is anyone out there that might have a good example of this, please let me know. I would love to show my class this.
Thanks.
Michael