Event Handling

M

Morten Fagermoen

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 ChangeEventHandler

Private Sub PhoneInfo_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim statePowerBatteryStrength As New
SystemState(SystemProperty.PowerBatteryStrength)
AddHandler statePowerBatteryStrength.Changed, AddressOf
ChangedPowerBatteryStrength
End Sub

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

Method 'Private Sub ChangedPowerBatteryStrength()' does not have the same
signature as delegate 'Delegate Sub ChangeEventHandler(sender As Object,
args As Microsoft.WindowsMobile.Status.ChangeEventArgs)'.


Regards

Morten Fagermoen
 
C

CWIZO

Make shure that the ChangedPowerBatteryStrength() accepts the same
types of parameters as the ChangeEventHandler delegate.

In your case you have to add: sender As Object,
args As Microsoft.WindowsMobile.Status.ChangeEventArgs
 
M

Morten Fagermoen

Thank you very much, Jan!!

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


Regards

Morten Fagermoen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top