Event Handling

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

    #1

    Event Handling

    Hello!

    I would like to make an event handler in a VB.NET 2005 project to check if
    the battery state changes on my Windows Mobile 5 device. But I don't manage
    to make this work, does anyone have an example for me?

    Her is a cut from my code:

    Public Shadows Event Changed As ChangeEventHand ler

    Private Sub PhoneInfo_Load( ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles MyBase.Load
    Dim statePowerBatte ryStrength As New
    SystemState(Sys temProperty.Pow erBatteryStreng th)
    AddHandler statePowerBatte ryStrength.Chan ged, AddressOf
    ChangedPowerBat teryStrength
    End Sub

    Private Sub ChangedPowerBat teryStrength()
    ShowInfo()
    End Sub
    *************** *
    The statement ....,AddressOf ChangedPowerBat teryStrength gives me an error
    that says:

    Method 'Private Sub ChangedPowerBat teryStrength()' does not have the same
    signature as delegate 'Delegate Sub ChangeEventHand ler(sender As Object,
    args As Microsoft.Windo wsMobile.Status .ChangeEventArg s)'.


    Regards

    Morten Fagermoen


  • CWIZO

    #2
    Re: Event Handling

    Make shure that the ChangedPowerBat teryStrength() accepts the same
    types of parameters as the ChangeEventHand ler delegate.

    In your case you have to add: sender As Object,
    args As Microsoft.Windo wsMobile.Status .ChangeEventArg s

    Comment

    • Morten Fagermoen

      #3
      Re: Event Handling

      Thank you very much, Jan!!

      This made it work and I learned something today to!!


      Regards

      Morten Fagermoen


      Comment

      • CWIZO

        #4
        Re: Event Handling

        You are welcome ;)

        Comment

        Working...