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

VB.NET to c# convert

P: n/a
Hey all

Our company recently started using .net and started in VB.NET. We've since
changed to c#, but has some code already written in VB.NET. I'm looking for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?

Nov 21 '05 #1
Share this Question
Share on Google+
22 Replies


P: n/a
There are none that are perfected. The best option is convert and fix.

One of the issues is there are training wheels available for VB.NET that are
not present in C#. While most of the converters do great translating VB.NET
to C#, when both are using .NET classes, the VB shortcuts often blow the
translation up. The more your team has used the VB functions, etc., the less
likely you have a clean translation. Most of the translator writers I have
conversed with are C# developers, so you can see the bias. ;-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
Hey all

Our company recently started using .net and started in VB.NET. We've since changed to c#, but has some code already written in VB.NET. I'm looking for a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?

Nov 21 '05 #2

P: n/a
Thanks...

Figured as much... Oh the joys / legacy of VB and the allowance of things
that just shouldn't be... ;)

"Cowboy (Gregory A. Beamer) [MVP]" <No************@comcast.netNoSpamM> wrote
in message news:%2****************@TK2MSFTNGP12.phx.gbl...
There are none that are perfected. The best option is convert and fix.

One of the issues is there are training wheels available for VB.NET that are not present in C#. While most of the converters do great translating VB.NET to C#, when both are using .NET classes, the VB shortcuts often blow the
translation up. The more your team has used the VB functions, etc., the less likely you have a clean translation. Most of the translator writers I have
conversed with are C# developers, so you can see the bias. ;-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
Hey all

Our company recently started using .net and started in VB.NET. We've

since
changed to c#, but has some code already written in VB.NET. I'm looking

for
a converter that will just take vb.net and convert it into farely nice c#. I've found one or two, but they do some strange stuff and was wondering if there is a Microsoft converter or one generally accepted as being good by the community?


Nov 21 '05 #3

P: n/a
Ya know what, I found that the conveters I used mostly work ok, they seem to
have trouble converting event handlers back into the delegate declaration
required by C#. Ive done a lot of translation both ways, and I find VB to C#
dead easy most of the time, but the other way is normally a bit of a pain.

Its a case of hacking it till it works Im afraid.


--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Thanks...

Figured as much... Oh the joys / legacy of VB and the allowance of things
that just shouldn't be... ;)

"Cowboy (Gregory A. Beamer) [MVP]" <No************@comcast.netNoSpamM> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
There are none that are perfected. The best option is convert and fix.

One of the issues is there are training wheels available for VB.NET that are
not present in C#. While most of the converters do great translating

VB.NET
to C#, when both are using .NET classes, the VB shortcuts often blow the
translation up. The more your team has used the VB functions, etc., the

less
likely you have a clean translation. Most of the translator writers I have
conversed with are C# developers, so you can see the bias. ;-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
Hey all

Our company recently started using .net and started in VB.NET. We've

since
changed to c#, but has some code already written in VB.NET. I'm
looking for
a converter that will just take vb.net and convert it into farely nice

c#. I've found one or two, but they do some strange stuff and was
wondering if there is a Microsoft converter or one generally accepted as being good by the community?



Nov 21 '05 #4

P: n/a
Michael,

I am just curious, since it is in VB.NET, why not leave compiled
assemblies as they are, and then just make sure all new development is done
in C#? All you have to do is add an assembly reference, and it works.

This way, you don't have to spend resources on something that is really
just a preference, and not a need (you gain almost nothing by changing the
code to C#).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Thanks...

Figured as much... Oh the joys / legacy of VB and the allowance of things
that just shouldn't be... ;)

"Cowboy (Gregory A. Beamer) [MVP]" <No************@comcast.netNoSpamM>
wrote
in message news:%2****************@TK2MSFTNGP12.phx.gbl...
There are none that are perfected. The best option is convert and fix.

One of the issues is there are training wheels available for VB.NET that

are
not present in C#. While most of the converters do great translating

VB.NET
to C#, when both are using .NET classes, the VB shortcuts often blow the
translation up. The more your team has used the VB functions, etc., the

less
likely you have a clean translation. Most of the translator writers I
have
conversed with are C# developers, so you can see the bias. ;-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
> Hey all
>
> Our company recently started using .net and started in VB.NET. We've

since
> changed to c#, but has some code already written in VB.NET. I'm
> looking

for
> a converter that will just take vb.net and convert it into farely nice c#. > I've found one or two, but they do some strange stuff and was wondering if > there is a Microsoft converter or one generally accepted as being good by > the community?
>
>
>



Nov 21 '05 #5

P: n/a
exactly. Whole point of the framework.
Otherwise what happens if your company changes it's mind again and goes for
C++.net or Python.net!
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ow*************@TK2MSFTNGP10.phx.gbl...
Michael,

I am just curious, since it is in VB.NET, why not leave compiled
assemblies as they are, and then just make sure all new development is done in C#? All you have to do is add an assembly reference, and it works.

This way, you don't have to spend resources on something that is really just a preference, and not a need (you gain almost nothing by changing the
code to C#).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Thanks...

Figured as much... Oh the joys / legacy of VB and the allowance of things that just shouldn't be... ;)

"Cowboy (Gregory A. Beamer) [MVP]" <No************@comcast.netNoSpamM>
wrote
in message news:%2****************@TK2MSFTNGP12.phx.gbl...
There are none that are perfected. The best option is convert and fix.

One of the issues is there are training wheels available for VB.NET that
are
not present in C#. While most of the converters do great translating

VB.NET
to C#, when both are using .NET classes, the VB shortcuts often blow
the translation up. The more your team has used the VB functions, etc., the

less
likely you have a clean translation. Most of the translator writers I
have
conversed with are C# developers, so you can see the bias. ;-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
> Hey all
>
> Our company recently started using .net and started in VB.NET. We've
since
> changed to c#, but has some code already written in VB.NET. I'm
> looking
for
> a converter that will just take vb.net and convert it into farely

nice c#.
> I've found one or two, but they do some strange stuff and was
wondering if
> there is a Microsoft converter or one generally accepted as being
good by
> the community?
>
>
>



Nov 21 '05 #6

P: n/a
Thats fine provided you are able to leave the compiled assemblies compiled,
if you need to maintaine them, this then becomes more of an issue.

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ow*************@TK2MSFTNGP10.phx.gbl...
Michael,

I am just curious, since it is in VB.NET, why not leave compiled
assemblies as they are, and then just make sure all new development is done in C#? All you have to do is add an assembly reference, and it works.

This way, you don't have to spend resources on something that is really just a preference, and not a need (you gain almost nothing by changing the
code to C#).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Thanks...

Figured as much... Oh the joys / legacy of VB and the allowance of things that just shouldn't be... ;)

"Cowboy (Gregory A. Beamer) [MVP]" <No************@comcast.netNoSpamM>
wrote
in message news:%2****************@TK2MSFTNGP12.phx.gbl...
There are none that are perfected. The best option is convert and fix.

One of the issues is there are training wheels available for VB.NET that
are
not present in C#. While most of the converters do great translating

VB.NET
to C#, when both are using .NET classes, the VB shortcuts often blow
the translation up. The more your team has used the VB functions, etc., the

less
likely you have a clean translation. Most of the translator writers I
have
conversed with are C# developers, so you can see the bias. ;-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
> Hey all
>
> Our company recently started using .net and started in VB.NET. We've
since
> changed to c#, but has some code already written in VB.NET. I'm
> looking
for
> a converter that will just take vb.net and convert it into farely

nice c#.
> I've found one or two, but they do some strange stuff and was
wondering if
> there is a Microsoft converter or one generally accepted as being
good by
> the community?
>
>
>



Nov 21 '05 #7

P: n/a
* "Michael Nicol" <mi**********@woolworths.co.za> scripsit:
Our company recently started using .net and started in VB.NET. We've since
changed to c#, but has some code already written in VB.NET. I'm looking for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?


I don't know a good converter for this purpose, but why don't simply
leave the code in VB.NET? This would save a lot of work and would not
have any disadvantages.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #8

P: n/a
I don't know a good converter for this purpose, but why don't simply
leave the code in VB.NET? This would save a lot of work and would not
have any disadvantages.


Read the message from OHM, I find that a good point.

And as Rakesh said, after too much C# it's always a bit of a chore to think
in
vb.net :)

Cor
Nov 21 '05 #9

P: n/a
Just out of curiosity, why did you change from VB.Net to C#?

André Nogueira

"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
Hey all

Our company recently started using .net and started in VB.NET. We've
since
changed to c#, but has some code already written in VB.NET. I'm looking
for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?

Nov 21 '05 #10

P: n/a
OK then, tell me how you would create a Unsigned Int in VB.NET, which you
can do in C#

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"mscertified" <ru****@tigerlily.com> wrote in message
news:15**********************************@microsof t.com...
One of the major selling points of .NET is that it is language independent, so its pointless converting source languages.

"Michael Nicol" wrote:
Hey all

Our company recently started using .net and started in VB.NET. We've since changed to c#, but has some code already written in VB.NET. I'm looking for a converter that will just take vb.net and convert it into farely nice c#. I've found one or two, but they do some strange stuff and was wondering if there is a Microsoft converter or one generally accepted as being good by the community?

Nov 21 '05 #11

P: n/a
I was wondering if you could do that, I needed it for a project... My
question is answered now =S

Andre Nogueira

"One Handed Man ( OHM - Terry Burns )" <news.microsoft.com> wrote in message
news:O$*************@TK2MSFTNGP10.phx.gbl...
OK then, tell me how you would create a Unsigned Int in VB.NET, which you
can do in C#

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"mscertified" <ru****@tigerlily.com> wrote in message
news:15**********************************@microsof t.com...
One of the major selling points of .NET is that it is language

independent,
so its pointless converting source languages.

"Michael Nicol" wrote:
> Hey all
>
> Our company recently started using .net and started in VB.NET. We've since > changed to c#, but has some code already written in VB.NET. I'm
> looking for > a converter that will just take vb.net and convert it into farely nice c#. > I've found one or two, but they do some strange stuff and was wondering if > there is a Microsoft converter or one generally accepted as being good by > the community?
>
>
>
>


Nov 21 '05 #12

P: n/a
<"One Handed Man \( OHM - Terry Burns \)" <news.microsoft.com>> wrote:
OK then, tell me how you would create a Unsigned Int in VB.NET, which you
can do in C#


Option Strict On

Imports System

Class Test

Shared Sub Main
Dim x as UInt32 = Convert.ToUInt32(0)
End Sub

End Class

There's not a lot you can do with it once you've created it,
admittedly, but you can create it...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 21 '05 #13

P: n/a
I realise this, I was making a point about language differences for the
benefit of the poster above me.

Cheers

--

OHM ( Terry Burns )
. . . One-Handed-Man . . .
If U Need My Email ,Ask Me

Time flies when you don't know what you're doing

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
<"One Handed Man \( OHM - Terry Burns \)" <news.microsoft.com>> wrote:
OK then, tell me how you would create a Unsigned Int in VB.NET, which you can do in C#


Option Strict On

Imports System

Class Test

Shared Sub Main
Dim x as UInt32 = Convert.ToUInt32(0)
End Sub

End Class

There's not a lot you can do with it once you've created it,
admittedly, but you can create it...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 21 '05 #14

P: n/a
Could you compile what you have and then use anakrino or similar to
decompile into c# source?

"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
Hey all

Our company recently started using .net and started in VB.NET. We've
since
changed to c#, but has some code already written in VB.NET. I'm looking
for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?

Nov 21 '05 #15

P: n/a
* "One Handed Man \( OHM - Terry Burns \)" <news.microsoft.com> scripsit:
OK then, tell me how you would create a Unsigned Int in VB.NET, which you
can do in C#


Unsigned integer datatypes are /not/ CLS compliant and should not be
used if not necessary. VB 2005 will provide full support for unsigned
types, but they will still remain not CLS compliant.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #16

P: n/a
I can see a reasoning in maintainability. If your company standardizes on
C#, you do not necessarily want to cross-train devs in VB.NET. I have no
problem in either language, but I can see good reasons to standardize, esp.
for smaller companies without many devs.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:Ow*************@TK2MSFTNGP10.phx.gbl...
Michael,

I am just curious, since it is in VB.NET, why not leave compiled
assemblies as they are, and then just make sure all new development is done in C#? All you have to do is add an assembly reference, and it works.

This way, you don't have to spend resources on something that is really just a preference, and not a need (you gain almost nothing by changing the
code to C#).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Thanks...

Figured as much... Oh the joys / legacy of VB and the allowance of things that just shouldn't be... ;)

"Cowboy (Gregory A. Beamer) [MVP]" <No************@comcast.netNoSpamM>
wrote
in message news:%2****************@TK2MSFTNGP12.phx.gbl...
There are none that are perfected. The best option is convert and fix.

One of the issues is there are training wheels available for VB.NET that
are
not present in C#. While most of the converters do great translating

VB.NET
to C#, when both are using .NET classes, the VB shortcuts often blow
the translation up. The more your team has used the VB functions, etc., the

less
likely you have a clean translation. Most of the translator writers I
have
conversed with are C# developers, so you can see the bias. ;-)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
> Hey all
>
> Our company recently started using .net and started in VB.NET. We've
since
> changed to c#, but has some code already written in VB.NET. I'm
> looking
for
> a converter that will just take vb.net and convert it into farely

nice c#.
> I've found one or two, but they do some strange stuff and was
wondering if
> there is a Microsoft converter or one generally accepted as being
good by
> the community?
>
>
>



Nov 21 '05 #17

P: n/a
I think the issue is the devs of the original used the "training wheels"
inherent in VB, which means the C# program, once decompiled, would have
references back to Microsoft.VisualBasic and
Microsoft.VisualBasic.Compatibility, adding weight that need not be there.
Decompilation is a good start.

If I were doing it this way, I would decompile and remove all VB reference
statements and fix all the explosions. It is an option. Salamander
decompiler is even sweeter, but a bit pricey for some shops.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"Peter Vervoorn" <ne******@vervoorn.com> wrote in message
news:41***********************@news.xs4all.nl...
Could you compile what you have and then use anakrino or similar to
decompile into c# source?

"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
Hey all

Our company recently started using .net and started in VB.NET. We've
since
changed to c#, but has some code already written in VB.NET. I'm looking
for
a converter that will just take vb.net and convert it into farely nice c#. I've found one or two, but they do some strange stuff and was wondering if there is a Microsoft converter or one generally accepted as being good by the community?


Nov 21 '05 #18

P: n/a
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message news:<u#**************@TK2MSFTNGP11.phx.gbl>...
Hey all

Our company recently started using .net and started in VB.NET. We've since
changed to c#, but has some code already written in VB.NET. I'm looking for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?


Hi Mike,

Our Decompiler.NET product does a good job with translating VB to C#
into high level readable code that compiles and runs correctly. It is
also priced very reasonably compared to some of the other
alternatives. You can download a free trial version and confirm that
it works well for you from our web site at:
http://www.junglecreatures.com/

Jonathan Pierce
President
Jungle Creatures, Inc.
http://www.junglecreatures.com/
Nov 21 '05 #19

P: n/a
Get a copy of Reflector (http://www.aisto.com/roeder/dotnet/) which allows
you to look at VB.net code in C# and vice versa. The file disassembler
add-in is quite useful to get the files written to disk
(http://www.denisbauer.com/NETTools/F...ssembler.aspx).

You can also find some VB.net to C# converters on Google
"Michael Nicol" <mi**********@woolworths.co.za> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl...
Hey all

Our company recently started using .net and started in VB.NET. We've
since
changed to c#, but has some code already written in VB.NET. I'm looking
for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?

Nov 21 '05 #20

P: n/a
I've been using http://www.instantcsharp.com/ on the csharpnuke.com project

It handles most of the vb.net to c# quirks,

I'd certainly recommend looking at it.
"Michael Nicol" wrote:
Hey all

Our company recently started using .net and started in VB.NET. We've since
changed to c#, but has some code already written in VB.NET. I'm looking for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?

Nov 21 '05 #21

P: n/a
There is tools that converts vb and vb.net to c#.
free download!!.
http://www.e-iceblue.com
Nov 21 '05 #22

P: n/a
You can use this link to convert page by page.
http://www.developerfusion.com/utili...btocsharp.aspx

"Michael Nicol" wrote:
Hey all

Our company recently started using .net and started in VB.NET. We've since
changed to c#, but has some code already written in VB.NET. I'm looking for
a converter that will just take vb.net and convert it into farely nice c#.
I've found one or two, but they do some strange stuff and was wondering if
there is a Microsoft converter or one generally accepted as being good by
the community?

Nov 21 '05 #23

This discussion thread is closed

Replies have been disabled for this discussion.