Hello Mike
In answer to the e-mail you send ( i like to keep it in the group so anyone
can benefit and / or join in the discussion )
here are 2 simple examples
Raiseevent option :
Public Class Form1
Private WithEvents account As New Account
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
account.DosomeCalcOnAccount()
End Sub
Private Sub account_eAccountLow(ByVal Amount As Decimal) Handles
account.eAccountLow
MsgBox("eAccountLow :Amount:" & Amount.ToString)
End Sub
Private Sub account_eAccountGotLowAmount(ByVal Amount As Decimal)
Handles account.eAccountGotLowAmount
MsgBox("eAccountGotLowAmount :Amount:" & Amount.ToString)
End Sub
End Class
Public Class Account
'option 1
Public Event eAccountLow(ByVal Amount As Decimal) 'ofcourse the event
arguments could be anything you like
Public Event eAccountGotLowAmount(ByVal Amount As Decimal)
Public Sub New()
'nothing needed here
End Sub
Public Sub DosomeCalcOnAccount()
'do some stuff in a sub routine
'dummy routine
Dim amount As Decimal = 1000
Do Until amount = 100
amount -= 1
Loop
'hey the account got low
'simplest solution ( although i like the next example more as it
binds both events )
RaiseEvent eAccountLow(amount)
RaiseEvent eAccountGotLowAmount(amount)
End Sub
End Class
Private handler option :
Public Class Form1
Private WithEvents account As New Account
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
account.DosomeCalcOnAccount()
End Sub
Private Sub account_eAccountLow(ByVal Amount As Decimal) Handles
account.eAccountLow
MsgBox("eAccountLow :Amount:" & Amount.ToString)
End Sub
Private Sub account_eAccountGotLowAmount(ByVal Amount As Decimal)
Handles account.eAccountGotLowAmount
MsgBox("eAccountGotLowAmount notice that i am raised through the
clas`s handler :Amount:" & Amount.ToString)
End Sub
End Class
Public Class Account
'option 1
Public Event eAccountLow(ByVal Amount As Decimal) 'ofcourse the event
arguments could be anything you like
Public Event eAccountGotLowAmount(ByVal Amount As Decimal)
Public Sub New()
AddHandler eAccountLow, AddressOf sAccountGotLowAmount
End Sub
Private Sub sAccountGotLowAmount(ByVal Amount As Decimal)
RaiseEvent eAccountGotLowAmount(Amount)
End Sub
Public Sub DosomeCalcOnAccount()
'do some stuff in a sub routine
'dummy routine
Dim amount As Decimal = 1000
Do Until amount = 100
amount -= 1
Loop
'hey the account got low
RaiseEvent eAccountLow(amount)
End Sub
End Class
when i tested this code it turned out that i was wrong in a previous
asumption
cause in the second example eAccountGotLowAmount is externally raised before
the event eAccountLow.
hth
Michel