By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,337 Members | 1,323 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,337 IT Pros & Developers. It's quick & easy.

VB.Net to C#. The problem of Delegate

P: n/a
Dear all:

I want to use a software API functions on my project,but it was written
VB.NET. I am using C#, So how to write these code by C#, espacially
Delegate. I tried several times, but I failed. The below is the part
code by VB.NET

------------------------------------------------------------------------------------------------
Sub DoOCR(ByRef FileName As String)
Dim cbFunc As SimpleOCX.outputHandlerDelegate
Dim ret As Interger
cbFunc = AddressOf myoutputhandler
ret = objOCR.OCRSetOutputHandlerX(cbFunc)
Exit Sub

Sub myoutputhandler(ByVal infotype As Short, ByVal param As Short)
End Sub
------------------------------------------------------------------------------------------------
Please give me some tip to do this process, I will appreciate your
kindness.
Thanks.

Mar 29 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Shi Cheng Yu,

You can use my Vb.Net to C# Code Converter
http://www.dotnettaxi.com/Tools/Converter.aspx for that. Don't forget to
paste a full class, otherwise the converter will not work.

--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
Mar 29 '06 #2

P: n/a
How wierd I replied to his thread and its not showing :<

"Ward Bekker" wrote:
Hi Shi Cheng Yu,

You can use my Vb.Net to C# Code Converter
http://www.dotnettaxi.com/Tools/Converter.aspx for that. Don't forget to
paste a full class, otherwise the converter will not work.

--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx

Mar 29 '06 #3

P: n/a

I posted this on the wrong thread before...
I replaced "Exit Sub" with "End Sub" at the end of DoOCR, I believe that is
how it should be.

VB.NET version:
_________________________________
Sub DoOCR(ByRef FileName As String)
Dim cbFunc As SimpleOCX.outputHandlerDelegate
Dim ret As Interger
cbFunc = AddressOf myoutputhandler
ret = objOCR.OCRSetOutputHandlerX(cbFunc)
End Sub

Sub myoutputhandler(ByVal infotype As Short, ByVal param As Short)
End Sub
_________________________________

C# .NET version
_________________________________
void DoOCR(ref string FileName)
{
SimpleOCX.outputHandlerDelegate cbFunc;
int ret;

cbFunc = new SimpleOCX.outputHandlerDelegate(myoutputhandler);
ret = objOCR.OCRSetOutputHandlerX(cbFunc);
}

void myoutputhandler(short infotype, short param)
{
}
_________________________________
Let me add that this code doesn't make any sense as FileName is never
assigned to and myoutputhandler has no code in it.

_________________________________

"Adam Right" wrote:
Hi,

Can i enumarate the windows form's components? I want to list components on
the screen. Thanks...
(Note: I am using vs2005)


Mar 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.