Hi Cerebrus,
Thanks for taking to the time to look at my query. Let me say that I
have used one of the online free code converters. Using this one:
http://www.developerfusion.com/tools/convert/vb-to-csharp/
I was able to convert the entire project to CV. It seemed to work well
except that the code I quoted above. This was converted to:
Private Sub CreateManager()
Try
wiaMgr = New WiaClass()
wiaEvtDisc = New _IWiaEvents_OnDeviceDisconnectedEventHandler
(Me.wia_OnDeviceDisconnected)
wiaMgr.OnDeviceDisconnected += wiaEvtDisc
wiaEvtTransfer = New _IWiaEvents_OnTransferCompleteEventHandler
(Me.wia_OnTransferComplete)
wiaMgr.OnTransferComplete += wiaEvtTransfer
Catch generatedExceptionName As Exception
MessageBox.Show(Me, "Create WIA manager object failed", "WIA",
MessageBoxButtons.OK, MessageBoxIcon.[Stop])
Application.[Exit]()
End Try
End Sub
The problem is, as I mentioned the line wiaMgr.OnDeviceDisconnected +=
wiaEvtDisc returns the following error:
" 'Public Event OnDeviceDisconnected(Id As String)' is an event, and
cannot be called directly. Use a 'RaiseEvent' statement to raise an
event."
And this is where my problems lie. I am aware of the .Net statements
AddHandler and RaiseEvent. I use them on a regular basis when I create
controls at run time . But in this case I am dealing with an event in
a seperate class and am not sure how to deal with it.
Btw there are two event call backs in the form:
Private wiaEvtDisc As _IWiaEvents_OnDeviceDisconnectedEventHandler
Private wiaEvtTransfer As _IWiaEvents_OnDeviceDisconnectedEventHandler
Any help would be appreciated. Sorry for not being more verbose in my
original post.
On 5 Aug, 18:29, Cerebrus <[email protected]> wrote:
> ~ What prevents you from using any of the myriad free code converters
> (VB -> C# or C# to VB) available online ?
> ~ What prevents you from researching Event Handlers ?
>
> Hint: Check out the AddHandler statement in VB.
>
> On Aug 5, 8:11 pm, waqas <[email protected]> wrote:
>
> > Can someone convert the following c# code (which can be found in this
> > codeproject
> > article:http://www.codeproject.com/KB/dotnet/wiascriptingdotnet.aspx)
> > to VB?
>
> > I have managed to convert the rest of the code to VB but I am having
> > trouble with this sub.
>
> > Particulary the line "wiaMgr.OnDeviceDisconnected += wiaEvtDisc;".