Quick question on C# to VB event conversion...

  • Thread starter Thread starter craig
  • Start date Start date
C

craig

I was wondering if someone could quickly tell me what the equivalnet to this
line of code in C# would be in VB....

item.IsDirtyChanged += new EventHandler(NotifyParent);

Thanks!
 
craig said:
I was wondering if someone could quickly tell me what the equivalnet to this
line of code in C# would be in VB....

item.IsDirtyChanged += new EventHandler(NotifyParent);

Thanks!

Craig,

Not sure about the "equvalency" but in VB you do the following...

In a class (form)
1) Declare an event
2) Write the code to send the event

In a client
1) Dim an reference to the class using "WithEvents"
2) (Using the object declaration drop-downs) add code to the event.

'class A
Event IsDirtyChanged() ' you can add parameters if you like
....
RaiseEvent IsDirtyChanged() ' raise the event to anyone listening
' end class A

'class B
Dim WithEvents MyA As A
....
Private Sub MyA_IsDirtyChanged()
End Sub
'
There are some nuances with parameters types, but you can look that up in
the help.

HTH
-ralph
 
Back
Top