473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VB.Net to C#. The problem of Delegate

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
3 1584
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
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kent | last post by:
The following is a greatly simplified example of what I would like to accomplish using the event/delegate features of .NET I have a class "NumGen" that produces a random set of numbers between 0...
0
by: Irfan | last post by:
I have a Delegate based Project that contain classes whose purpose is to instantiate objects of another Project (or Library) using Delegates. I have a client application that uses this Delegate...
4
by: Dean Bortell | last post by:
I am writing a multi-threaded program with a worker thread. I want the rich text box to auto scroll down as the text is added. Here is what I want to happen: From the worker thread: 1. Add the...
5
by: Cosmin Prund | last post by:
Hello everyone. I'm new to c# and I'm trying to use some delegates in my code, so I can do time-tests on whatever I'm doing. In order to do this I tried writing a testing method that will make use...
2
by: Tim::.. | last post by:
Can someone tell me why I get this error??? And how do I fix it?? Thanks Compiler Error Message: BC30408: Method 'Public Sub UploadData()' does not have the same signature as delegate...
14
by: Christian Kaiser | last post by:
We have a component that has no window. Well, no window in managed code - it uses a DLL which itself uses a window, and this is our problem! When the garbage collector runs and removes our...
6
by: per9000 | last post by:
An interesting/annoying problem. I created a small example to provoke an exception I keep getting. Basically I have a C-struct (Container) with a function-pointer in it. I perform repeated calls...
3
by: james | last post by:
Hi guys, I create a delegate and pass in a local variable. When the variable is a reference type everything works fine, but when it is a valuetype the delegate uses the value of the last...
1
by: Robert Dufour | last post by:
I am trying to sort the membership list of the membership provider for ASP.NET the code has retrieved the list and now we need to sort it by a parameter if it was passed. So in C# the code is....
9
by: raylopez99 | last post by:
Hello all— I’m trying to get the below to work and cannot get the format right. It’s from this example: http://msdn.microsoft.com/en-us/library/8627sbea(VS.71).aspx What it is: I’m trying...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.