RaiseEvent not firing...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • hzgt9b

    RaiseEvent not firing...

    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(B yVal sender As
    System.Object, ByVal e As System.EventArg s) Handles btnTest.Click
    'In my main form, I create a new instance of another form, then open
    it.
    frmLogin = New frmDomainLogin( Me)
    frmLogin.ShowDi alog(Me) 'Wait here
    till the form closes...
    End Sub

    Private Sub frmErrLog_LogEr ror(ByVal strMethod
    As String, ByVal strMessage As String) Handles frmErrLog.LogEr ror
    '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(somePa rameter as Object)

    Private Sub frmDomainLogin_ Load(ByVal sender
    As Object, ByVal e As System.EventArg s) Handles Me.Load
    RaiseEvent LogError(Now & "
    raising test event...")
    End Sub

    End Class
    '------------------------------------------------------------------------------

  • hzgt9b

    #2
    Re: RaiseEvent not firing...

    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 frmLogin As frmDomainLogin

    Private Sub btnTest_Click(B yVal sender As
    System.Object, ByVal e As System.EventArg s) Handles btnTest.Click
    'In my main form, I create a new instance of another form, then open
    it.
    frmLogin = New frmDomainLogin( Me)
    frmLogin.ShowDi alog(Me) 'Wait here
    till the form closes...
    End Sub

    Private Sub frmErrLog_LogEr ror(ByVal strMethod
    As String, ByVal strMessage As String) Handles frmErrLog.LogEr ror
    '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(somePa rameter as Object)

    Private Sub frmDomainLogin_ Load(ByVal sender
    As Object, ByVal e As System.EventArg s) Handles Me.Load
    RaiseEvent LogError(Now & "
    raising test event...")
    End Sub

    End Class
    '------------------------------------------------------------------------------

    Comment

    • hzgt9b

      #3
      Re: RaiseEvent not firing...

      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 frmLogin As frmDomainLogin

      Private Sub btnTest_Click(B yVal sender As
      System.Object, ByVal e As System.EventArg s) Handles btnTest.Click
      'In my main form, I create a new instance of another form, then open
      it.
      frmLogin = New frmDomainLogin( Me)
      frmLogin.ShowDi alog(Me) 'Wait here
      till the form closes...
      End Sub

      Private Sub frmErrLog_LogEr ror(ByVal strMethod
      As String, ByVal strMessage As String) Handles frmErrLog.LogEr ror
      '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(somePa rameter as Object)

      Private Sub frmDomainLogin_ Load(ByVal sender
      As Object, ByVal e As System.EventArg s) Handles Me.Load
      RaiseEvent LogError(Now & "
      raising test event...")
      End Sub

      End Class
      '------------------------------------------------------------------------------

      Comment

      • Armin Zingler

        #4
        Re: RaiseEvent not firing...

        "hzgt9b" <celoftis@gmail .comschrieb
        Private WithEvents frmLogin As frmDomainLogin
        frmLogin = New frmDomainLogin( Me)
        Private Sub frmErrLog_LogEr ror(ByVal
        strMethod As String, ByVal strMessage As String) Handles
        frmErrLog.LogEr ror 'In my main form, I want to catch the events
        raised from the other form... but this code never gets executed...
        why not?
        "Handles frmErrLog.LogEr ror": Above you write frmLogin, not frmErrLog. Is
        this accidently in this posting?


        Armin


        Comment

        • hzgt9b

          #5
          Re: RaiseEvent not firing...

          Armin,
          Yes, that was a typo... consider frmLogin and frmErrLog the same form.

          Comment

          • =?Utf-8?B?S2VycnkgTW9vcm1hbg==?=

            #6
            RE: RaiseEvent not firing...

            hzgt9b,

            I tried re-creating your scenario in a simple example and I did not have any
            problems raising an event in a form being shown modally and handling the
            event in the parent form.

            Perhaps something else in your application is complicating the situation.

            Kerry Moorman


            "hzgt9b" wrote:
            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(B yVal sender As
            System.Object, ByVal e As System.EventArg s) Handles btnTest.Click
            'In my main form, I create a new instance of another form, then open
            it.
            frmLogin = New frmDomainLogin( Me)
            frmLogin.ShowDi alog(Me) 'Wait here
            till the form closes...
            End Sub
            >
            Private Sub frmErrLog_LogEr ror(ByVal strMethod
            As String, ByVal strMessage As String) Handles frmErrLog.LogEr ror
            '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(somePa rameter as Object)
            >
            Private Sub frmDomainLogin_ Load(ByVal sender
            As Object, ByVal e As System.EventArg s) Handles Me.Load
            RaiseEvent LogError(Now & "
            raising test event...")
            End Sub
            >
            End Class
            '------------------------------------------------------------------------------
            >
            >

            Comment

            • Armin Zingler

              #7
              Re: RaiseEvent not firing...

              "hzgt9b" <celoftis@gmail .comschrieb
              Armin,
              Yes, that was a typo... consider frmLogin and frmErrLog the same
              form.
              Then I don't see an error in the code.


              Armin

              Comment

              • Harry

                #8
                Re: RaiseEvent not firing...

                "hzgt9b" <celoftis@gmail .comwrote in message
                news:1192204836 .236077.18070@z 24g2000prh.goog legroups.com...
                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(B yVal sender As
                System.Object, ByVal e As System.EventArg s) Handles btnTest.Click
                'In my main form, I create a new instance of another form, then open
                it.
                frmLogin = New frmDomainLogin( Me)
                frmLogin.ShowDi alog(Me) 'Wait here
                till the form closes...
                End Sub
                >
                Private Sub frmErrLog_LogEr ror(ByVal strMethod
                As String, ByVal strMessage As String) Handles frmErrLog.LogEr ror
                '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(somePa rameter as Object)
                >
                Private Sub frmDomainLogin_ Load(ByVal sender
                As Object, ByVal e As System.EventArg s) Handles Me.Load
                RaiseEvent LogError(Now & "
                raising test event...")
                End Sub
                >
                End Class
                '------------------------------------------------------------------------------
                >
                I have had problems with the same thing. Code that worked for the last 12
                months suddently stopped responding to a raised event. I suspect that given
                certain very bizarre conditions, VB.Net is causing this. Sadly, I was never
                able to find the answer. Other events continue to work fine.
                I resolved the problem by using binding rather than raise an event of my
                own...Not much of an answer, but days of trying different things, including
                deleting and rewriting a class, proved futile.


                Comment

                • Harry

                  #9
                  Re: RaiseEvent not firing...

                  "hzgt9b" <celoftis@gmail .comwrote in message
                  news:1192204836 .236077.18070@z 24g2000prh.goog legroups.com...
                  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(B yVal sender As
                  System.Object, ByVal e As System.EventArg s) Handles btnTest.Click
                  'In my main form, I create a new instance of another form, then open
                  it.
                  frmLogin = New frmDomainLogin( Me)
                  frmLogin.ShowDi alog(Me) 'Wait here
                  till the form closes...
                  End Sub
                  >
                  Private Sub frmErrLog_LogEr ror(ByVal strMethod
                  As String, ByVal strMessage As String) Handles frmErrLog.LogEr ror
                  '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(somePa rameter as Object)
                  >
                  Private Sub frmDomainLogin_ Load(ByVal sender
                  As Object, ByVal e As System.EventArg s) Handles Me.Load
                  RaiseEvent LogError(Now & "
                  raising test event...")
                  End Sub
                  >
                  End Class
                  '------------------------------------------------------------------------------
                  >
                  Just to show you are not alone with this problem, try a Google on "VB.Net +
                  RaiseEvent not firing"


                  Comment

                  • Lloyd Sheen

                    #10
                    Re: RaiseEvent not firing...


                    "Harry" <harry_NOSPAM@f fapaysmart.com. auwrote in message
                    news:uA6X7QqDIH A.5752@TK2MSFTN GP02.phx.gbl...
                    "hzgt9b" <celoftis@gmail .comwrote in message
                    news:1192204836 .236077.18070@z 24g2000prh.goog legroups.com...
                    >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(B yVal sender As
                    >System.Objec t, ByVal e As System.EventArg s) Handles btnTest.Click
                    >'In my main form, I create a new instance of another form, then open
                    >it.
                    > frmLogin = New frmDomainLogin( Me)
                    > frmLogin.ShowDi alog(Me) 'Wait here
                    >till the form closes...
                    > End Sub
                    >>
                    > Private Sub frmErrLog_LogEr ror(ByVal strMethod
                    >As String, ByVal strMessage As String) Handles frmErrLog.LogEr ror
                    >'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(somePa rameter as Object)
                    >>
                    > Private Sub frmDomainLogin_ Load(ByVal sender
                    >As Object, ByVal e As System.EventArg s) Handles Me.Load
                    > RaiseEvent LogError(Now & "
                    >raising test event...")
                    > End Sub
                    >>
                    > End Class
                    >'------------------------------------------------------------------------------
                    >>
                    Just to show you are not alone with this problem, try a Google on "VB.Net
                    + RaiseEvent not firing"
                    >
                    I did the google and noticed something that is similar to what you have.
                    Your event does not follow the ".net" signature with the first parameter
                    being the object which raised the event and the second parameter depending
                    on what is sent but is inherited from the EventArgs class.

                    Try changing your events to follow this pattern.

                    Can't hurt.

                    LS

                    Comment

                    • hzgt9b

                      #11
                      Re: RaiseEvent not firing...

                      THanks foe all the replies.

                      Comment

                      Working...