H
hzgt9b
Using VS2005, VB.NET,
I am developing a windows app. The application opens a couple of
forms. While the forms are open I want to raise some events, such as
logging errors - but I call RaiseEvent, nothing happens. Below are
some code snippets that show what I am doing. Can someone straighten
me out... I feel like this must be something real simple...
'------------------------------------------------------------------------------
Public Class frmMain
'In my main form, I declare my form with events so I can handle them
later...
Private WithEvents frmErrLog As frmErrorLog
Private Sub btnTest_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
'In my main form, I create a new instance of another form, then open
it.
frmLogin = New frmDomainLogin(Me)
frmLogin.ShowDialog(Me) 'Wait here
till the form closes...
End Sub
Private Sub frmErrLog_LogError(ByVal strMethod
As String, ByVal strMessage As String) Handles frmErrLog.LogError
'In my main form, I want to catch the events raised from the other
form... but this code never gets executed... why not?
Msgbox("Logging error:" &
vbnewline & strMethod & vbnewline & strMessage)
End Sub
End Class
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
Public Class frmDomainLogin
'So, here I declare my event, for use later...
Public Event LogError(someParameter as Object)
Private Sub frmDomainLogin_Load(ByVal sender
As Object, ByVal e As System.EventArgs) Handles Me.Load
RaiseEvent LogError(Now & "
raising test event...")
End Sub
End Class
'------------------------------------------------------------------------------
I am developing a windows app. The application opens a couple of
forms. While the forms are open I want to raise some events, such as
logging errors - but I call RaiseEvent, nothing happens. Below are
some code snippets that show what I am doing. Can someone straighten
me out... I feel like this must be something real simple...
'------------------------------------------------------------------------------
Public Class frmMain
'In my main form, I declare my form with events so I can handle them
later...
Private WithEvents frmErrLog As frmErrorLog
Private Sub btnTest_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
'In my main form, I create a new instance of another form, then open
it.
frmLogin = New frmDomainLogin(Me)
frmLogin.ShowDialog(Me) 'Wait here
till the form closes...
End Sub
Private Sub frmErrLog_LogError(ByVal strMethod
As String, ByVal strMessage As String) Handles frmErrLog.LogError
'In my main form, I want to catch the events raised from the other
form... but this code never gets executed... why not?
Msgbox("Logging error:" &
vbnewline & strMethod & vbnewline & strMessage)
End Sub
End Class
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
Public Class frmDomainLogin
'So, here I declare my event, for use later...
Public Event LogError(someParameter as Object)
Private Sub frmDomainLogin_Load(ByVal sender
As Object, ByVal e As System.EventArgs) Handles Me.Load
RaiseEvent LogError(Now & "
raising test event...")
End Sub
End Class
'------------------------------------------------------------------------------