473,405 Members | 2,261 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,405 software developers and data experts.

Help with C# to VB.Net Conversion

Hello,
I am a C# developer and am now starting to do some work in VB.NET and for
the life of me cant get something working the way I cant.

If anyone can offer any suggestions on how to convert this c# into Working
VB.Net code that would be great.

C# Class to be converted to VB.Net

I cant seem to get this line to work FireAsync(Completed, this,
EventArgs.Empty);
Class........

public event EventHandler Completed;
...
...
...
private void someMethod()
{
FireAsync(Completed, this, EventArgs.Empty);
}
protected void FireAsync(Delegate dlg, params object[] pList)
{
if (dlg != null)
{
Target.BeginInvoke(dlg, pList);
}
}

end class

VB.Net calling Code

Public MustInherit Class GridData
Inherits AsyncUtilities.AsyncOperation

AddHandler mobjData.Completed, AddressOf DataLoad_Finished
AddHandler mobjData.Cancelled, AddressOf DataLoad_Cancelled
AddHandler mobjData.Failed, New
System.Threading.ThreadExceptionEventHandler(Addre ssOf DataLoad_Failed)
Oct 30 '08 #1
6 2686
http://converter.telerik.com/
"Daniel Jeffrey" <Da***********@discussions.microsoft.comwrote in message
news:2B**********************************@microsof t.com...
Hello,
I am a C# developer and am now starting to do some work in VB.NET and for
the life of me cant get something working the way I cant.

If anyone can offer any suggestions on how to convert this c# into Working
VB.Net code that would be great.

C# Class to be converted to VB.Net

I cant seem to get this line to work FireAsync(Completed, this,
EventArgs.Empty);
Class........

public event EventHandler Completed;
...
...
...
private void someMethod()
{
FireAsync(Completed, this, EventArgs.Empty);
}
protected void FireAsync(Delegate dlg, params object[] pList)
{
if (dlg != null)
{
Target.BeginInvoke(dlg, pList);
}
}

end class

VB.Net calling Code

Public MustInherit Class GridData
Inherits AsyncUtilities.AsyncOperation

AddHandler mobjData.Completed, AddressOf DataLoad_Finished
AddHandler mobjData.Cancelled, AddressOf DataLoad_Cancelled
AddHandler mobjData.Failed, New
System.Threading.ThreadExceptionEventHandler(Addre ssOf DataLoad_Failed)

Oct 30 '08 #2
This produces the same result I got when I did it myself

'Public Event Completed(sender As Object, e As System.EventArgs)' is an
event, and cannot be called directly. Use a 'RaiseEvent' statement to raise
an event.
"Andy B" wrote:
http://converter.telerik.com/
"Daniel Jeffrey" <Da***********@discussions.microsoft.comwrote in message
news:2B**********************************@microsof t.com...
Hello,
I am a C# developer and am now starting to do some work in VB.NET and for
the life of me cant get something working the way I cant.

If anyone can offer any suggestions on how to convert this c# into Working
VB.Net code that would be great.

C# Class to be converted to VB.Net

I cant seem to get this line to work FireAsync(Completed, this,
EventArgs.Empty);
Class........

public event EventHandler Completed;
...
...
...
private void someMethod()
{
FireAsync(Completed, this, EventArgs.Empty);
}
protected void FireAsync(Delegate dlg, params object[] pList)
{
if (dlg != null)
{
Target.BeginInvoke(dlg, pList);
}
}

end class

VB.Net calling Code

Public MustInherit Class GridData
Inherits AsyncUtilities.AsyncOperation

AddHandler mobjData.Completed, AddressOf DataLoad_Finished
AddHandler mobjData.Cancelled, AddressOf DataLoad_Cancelled
AddHandler mobjData.Failed, New
System.Threading.ThreadExceptionEventHandler(Addre ssOf DataLoad_Failed)


Oct 30 '08 #3
"Daniel Jeffrey" <Da***********@discussions.microsoft.comschrieb
This produces the same result I got when I did it myself

'Public Event Completed(sender As Object, e As System.EventArgs)' is an
event, and cannot be called directly. Use a 'RaiseEvent' statement to
raise
an event.
VB does something under the hood. The implicitly declared delegate is called
CompletedEventHandler and the instance is called CompletedEvent. So, try
passing 'CompletedEvent', not 'Completed', if a Delegate is expected.
Untested.
Armin
Oct 30 '08 #4
thanks this worked.

Who ever said C# and VB.Net are "fundamentally" the same, never moved from 1
to the other

Dan

"Armin Zingler" <az*******@freenet.dewrote in message
news:eB**************@TK2MSFTNGP05.phx.gbl...
"Daniel Jeffrey" <Da***********@discussions.microsoft.comschrieb
>This produces the same result I got when I did it myself

'Public Event Completed(sender As Object, e As System.EventArgs)' is an
event, and cannot be called directly. Use a 'RaiseEvent' statement to
raise
an event.

VB does something under the hood. The implicitly declared delegate is
called
CompletedEventHandler and the instance is called CompletedEvent. So, try
passing 'CompletedEvent', not 'Completed', if a Delegate is expected.
Untested.
Armin

Oct 30 '08 #5
Daniel,

You are translating code not converting.

In VB.Net there is the easy keyword WithEvents, try that as you convert,
instead of difficult ways as it has to be done in C# which can be easily
done in VB for Net.

http://msdn.microsoft.com/en-us/library/aty3352y.aspx

Cor

"Daniel Jeffrey" <Da***********@discussions.microsoft.comwrote in message
news:2B**********************************@microsof t.com...
Hello,
I am a C# developer and am now starting to do some work in VB.NET and for
the life of me cant get something working the way I cant.

If anyone can offer any suggestions on how to convert this c# into Working
VB.Net code that would be great.

C# Class to be converted to VB.Net

I cant seem to get this line to work FireAsync(Completed, this,
EventArgs.Empty);
Class........

public event EventHandler Completed;
...
...
...
private void someMethod()
{
FireAsync(Completed, this, EventArgs.Empty);
}
protected void FireAsync(Delegate dlg, params object[] pList)
{
if (dlg != null)
{
Target.BeginInvoke(dlg, pList);
}
}

end class

VB.Net calling Code

Public MustInherit Class GridData
Inherits AsyncUtilities.AsyncOperation

AddHandler mobjData.Completed, AddressOf DataLoad_Finished
AddHandler mobjData.Cancelled, AddressOf DataLoad_Cancelled
AddHandler mobjData.Failed, New
System.Threading.ThreadExceptionEventHandler(Addre ssOf DataLoad_Failed)
Oct 30 '08 #6
Yea. I found problems with that converter now that I looked at it. I
converted some base classes for custom providers and it broke the code.
"Daniel Jeffrey" <Da***********@discussions.microsoft.comwrote in message
news:F5**********************************@microsof t.com...
This produces the same result I got when I did it myself

'Public Event Completed(sender As Object, e As System.EventArgs)' is an
event, and cannot be called directly. Use a 'RaiseEvent' statement to
raise
an event.
"Andy B" wrote:
>http://converter.telerik.com/
"Daniel Jeffrey" <Da***********@discussions.microsoft.comwrote in
message
news:2B**********************************@microso ft.com...
Hello,
I am a C# developer and am now starting to do some work in VB.NET and
for
the life of me cant get something working the way I cant.

If anyone can offer any suggestions on how to convert this c# into
Working
VB.Net code that would be great.

C# Class to be converted to VB.Net

I cant seem to get this line to work FireAsync(Completed, this,
EventArgs.Empty);
Class........

public event EventHandler Completed;
...
...
...
private void someMethod()
{
FireAsync(Completed, this, EventArgs.Empty);
}
protected void FireAsync(Delegate dlg, params object[] pList)
{
if (dlg != null)
{
Target.BeginInvoke(dlg, pList);
}
}

end class

VB.Net calling Code

Public MustInherit Class GridData
Inherits AsyncUtilities.AsyncOperation

AddHandler mobjData.Completed, AddressOf
DataLoad_Finished
AddHandler mobjData.Cancelled, AddressOf
DataLoad_Cancelled
AddHandler mobjData.Failed, New
System.Threading.ThreadExceptionEventHandler(Addre ssOf DataLoad_Failed)



Oct 30 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Thames | last post by:
Hi, I have to repost my question for help. Yesterday I set up two DB UDB ESE V8.2 server on linux and windows platform, respectively. Both servers have been connected without any problems...
27
by: Chuck Grimsby | last post by:
(Repost, due to lack of submissions...) The Microsoft Access Product Group (the people who build Microsoft Access) want your help! One of the main things we're working on for the near future...
11
by: Marcus Jacobs | last post by:
Dear Group I have written a file conversion program that uses strtof to convert text strings to floats. It works as I intended except for my error messages. It is my understanding that strtof...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
4
by: Gregory Edigaroff | last post by:
Hello, Everybody! Ok, I urgently need the solution for a following task in C++. This is the task from programmers contest, so I believe somebody have a solution for it. I need either a full...
0
by: k1ckthem1dget | last post by:
I need to display the unsorted list of names and display the sorted list of names. My program is getting a bunch of errors though, and i dont know why. I am getting the following errors. 28:...
2
by: k1ckthem1dget | last post by:
I need to display the unsorted list of names and display the sorted list of names. My program is getting a bunch of errors though, and i dont know why. I am getting the following errors. 28:...
1
by: Dancefire | last post by:
Hi, everyone, I'm trying to use std::codecvt<to do the encoding conversion. I am using following code for encoding conversion between wchar_t string and char string(MBCS). I am not sure am I...
2
by: gcook | last post by:
Hello, I need some help! I need to genreate a set of test inputs and expected results for the currency conversion program below. I also have to use the folowing format Test Case <put number...
5
by: Ivan Velev | last post by:
Hello, Minimal example below - it gives me different output if I comment / uncomment the extra time.mktime call - note that this call is not related in any way to main logic flow. When...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.