i'm trying to include the hardware buttons control posted by
mastermind at

http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=283&SearchTerms=hardware,buttons

in my vb.net project, but am having some trouble converting the
author's c# example to vb.net. particularly with creating the events.

here is what i have, and the errors i am getting

any help appreciated


captureHButtons = New CaptureHButtonsControl.CaptureHButtons

'//
'// captureHButtons
'//
'tried to convert this line to vb.net:
' this.captureHButtons.BindedButtonPressed += new
CaptureHButtonsControl.CaptureHButtons.KeyUpEventHandler(this.captureButtons_BindedButtonPressed);
'next line gives the following error:
' Public Event BindedButtonPressed(KeyCode As Integer)' is an event,
' and cannot be called directly.
' Use a 'RaiseEvent' statement to raise an event.
' and
' CaptureHButtonsControl.CaptureHButtons.CapturedButtonEventHandler'
is a delegate type.
' Delegate construction permits only a single AddressOf expression as
an argument list.
' Often an AddressOf expression can be used instead of a delegate
construction.
Me.captureHButtons.BindedButtonPressed += New
CaptureHButtonsControl.CaptureHButtons.CapturedButtonEventHandler(Me.captureButtons_BindedButtonPressed)

'tried to convert this line to vb.net:
' this.captureHButtons.RegisteredButtonPressed += new
CaptureHButtonsControl.CaptureHButtons.CapturedButtonEventHandler(this.captureButtons_RegisteredButtonPressed);
'next line gives the following error:
' Public Event BindedButtonPressed(KeyCode As Integer)' is an event,
' and cannot be called directly.
' Use a 'RaiseEvent' statement to raise an event.
' and
' CaptureHButtonsControl.CaptureHButtons.CapturedButtonEventHandler'
is a delegate type.
' Delegate construction permits only a single AddressOf expression as
an argument list.
' Often an AddressOf expression can be used instead of a delegate
construction.
Me.captureHButtons.RegisteredButtonPressed += New
CaptureHButtonsControl.CaptureHButtons.CapturedButtonEventHandler(Me.captureButtons_RegisteredButtonPressed)

Re: confusion creating events & delegates (reading hardware buttons, opennetcf) by Kevin

Kevin
Wed Jul 07 22:08:15 CDT 2004

Delegates is one topic where the C# syntax and VB syntax is very different.

'Declare your variable of type
CaptureHButtonsControl.CaptureHButtons.KeyUpEventHandler

Dim keyupHandler as
CaptureHButtonsControl.CaptureHButtons.KeyUpEventHandler

'Assign it a method to be the event handler

AddHandler keyupHandler , AddressOf
(this.captureButtons_BindedButtonPressed)

The method signature of captureButtons_BindedButtonPressed() must match
Public Event BindedButtonPressed(KeyCode As Integer) - e.g. have one
Integer parameter.

To invoke call RaiseEvent. i is an integer as required by the method
RaiseEvent keyupHandler(i)

FYI, you could have multiple methods be invoked for the KeyUpEvent:

AddHandler keyupHandler , AddressOf
(this.captureButtons_BindedButtonPressed_other)
AddHandler keyupHandler , AddressOf
(this.captureButtons_BindedButtonPressed_again)
AddHandler keyupHandler , AddressOf
(this.captureButtons_BindedButtonPressed_andMore)

This is the equivalenet of the C# syntax using the += operator

this.captureHButtons.BindedButtonPressed += new
CaptureHButtonsControl.CaptureHButtons.KeyUpEventHandler


Good luck,
kevin aubuchon

"Mad Scientist Jr" <usenet_daughter@yahoo.com> wrote in message
news:7a93f3c4.0407071414.61fe3899@posting.google.com...
> i'm trying to include the hardware buttons control posted by
> mastermind at
>
>
http://www.opennetcf.org/forums/topic.asp?TOPIC_ID=283&SearchTerms=hardware,buttons
>
> in my vb.net project, but am having some trouble converting the
> author's c# example to vb.net. particularly with creating the events.
>
> here is what i have, and the errors i am getting
>
> any help appreciated
>
>
> captureHButtons = New CaptureHButtonsControl.CaptureHButtons
>
> '//
> '// captureHButtons
> '//
> 'tried to convert this line to vb.net:
> ' this.captureHButtons.BindedButtonPressed += new
>
CaptureHButtonsControl.CaptureHButtons.KeyUpEventHandler(this.captureButtons
_BindedButtonPressed);
> 'next line gives the following error:
> ' Public Event BindedButtonPressed(KeyCode As Integer)' is an event,
> ' and cannot be called directly.
> ' Use a 'RaiseEvent' statement to raise an event.
> ' and
> ' CaptureHButtonsControl.CaptureHButtons.CapturedButtonEventHandler'
> is a delegate type.
> ' Delegate construction permits only a single AddressOf expression as
> an argument list.
> ' Often an AddressOf expression can be used instead of a delegate
> construction.
> Me.captureHButtons.BindedButtonPressed += New
>
CaptureHButtonsControl.CaptureHButtons.CapturedButtonEventHandler(Me.capture
Buttons_BindedButtonPressed)
>
> 'tried to convert this line to vb.net:
> ' this.captureHButtons.RegisteredButtonPressed += new
>
CaptureHButtonsControl.CaptureHButtons.CapturedButtonEventHandler(this.captu
reButtons_RegisteredButtonPressed);
> 'next line gives the following error:
> ' Public Event BindedButtonPressed(KeyCode As Integer)' is an event,
> ' and cannot be called directly.
> ' Use a 'RaiseEvent' statement to raise an event.
> ' and
> ' CaptureHButtonsControl.CaptureHButtons.CapturedButtonEventHandler'
> is a delegate type.
> ' Delegate construction permits only a single AddressOf expression as
> an argument list.
> ' Often an AddressOf expression can be used instead of a delegate
> construction.
> Me.captureHButtons.RegisteredButtonPressed += New
>
CaptureHButtonsControl.CaptureHButtons.CapturedButtonEventHandler(Me.capture
Buttons_RegisteredButtonPressed)