Naigewron
Member
Hi!
I have a bit of a conundrum. I have a VB.net module where I declare some global variables (and since they're in a module, they're also shared). Now, I declared them like so:
The events they raise are declared and raised like so (simplified):
Now, I attempt to write an event handler for this event on one of my forms:
However, the compiler kindly notifies me that "Handles clause requires a WithEvents variable defined in the containing type or one of its base types."
Now, the g_Customer object is, as you can see, declared "WithEvents", and there is no way of declaring an instance of a module (nor would I want to). So, am I simply missing something, or can I not raise events in objects declared inside a module?
Thanks for any help and pointers!
Eskil
I have a bit of a conundrum. I have a VB.net module where I declare some global variables (and since they're in a module, they're also shared). Now, I declared them like so:
VB.NET:
Module modGlobals
Public WithEvents g_Customer As New Customer()
Public WithEvents g_Ord As New Order()
End Module
The events they raise are declared and raised like so (simplified):
VB.NET:
' Declare eventhandler
Public Event CustomerUpdated As eventhandler
Public Sub UpdateCustomer(ByVal dt As DataTable)
' Do stuff and raise the event
RaiseEvent CustomerUpdated(Me, New System.EventArgs)
End Sub
Now, I attempt to write an event handler for this event on one of my forms:
VB.NET:
Public Sub g_Customer_CustomerUpdated(ByVal sender As Object, ByVal e As System.EventArgs) Handles g_Customer.CustomerUpdated
'Do stuff
End Sub
However, the compiler kindly notifies me that "Handles clause requires a WithEvents variable defined in the containing type or one of its base types."
Now, the g_Customer object is, as you can see, declared "WithEvents", and there is no way of declaring an instance of a module (nor would I want to). So, am I simply missing something, or can I not raise events in objects declared inside a module?
Thanks for any help and pointers!
Eskil