views:

329

answers:

8

What's the fastest way to convert an existing Vb6.0 win-based application into a c# win-based?

+10  A: 

The core language is so different, that I would have to say start from scratch, and copy only the complicated code bits. If you start from scratch you won't have to deal with all the VB6 problems, while utilizing all the C# power.

VB6 has no real classes or OOP, which makes very different from C#. Also, there is very little control on the event manager (SubClassing).

So, start from zero, copy the UI layout, and think about how would I implement this in C# in the first place, it will make your life easier.

Am
+8  A: 

I think the fastest would be to convert it to VB.net. Check the following question for this answer

VB6 to VB.net conversion

ans then converting it to c#. But I feel converting manually will be the better option as you can re engineer the application and may be make it simpler.

Shoban
Beat me by 24 seconds and had a link too - +1
Antony Koch
@Antony ;) ....
Shoban
I really think that using the converter is a bad idea. It misses a lot of the concepts introduced on .Net. (+1 though for actually giving a solution)
Am
OP asked for "fastest" not "prettiest" answer.
Ira Baxter
+2  A: 

Total rewrite. MS has some migration assistance, but I believe it's VB.Net only. But why look at porting, surely you'd be better off now rewriting the app, and just interop if you have any legacy parts that you need to keep alive. And only migrate the best bits. Use this as a chance to truly improve the application.

Kevin
+1  A: 

If you need it quickly; then don't go hand cranking it - you'll miss stuff out and tear your hair out!

I investigated this product a couple of years back and I felt this product was the best. it converts from VB6 to C#. They have a free trial too.

Martin Clarke
A: 

If your VB6 application is well written then it may be worth the effort to port the business logic. Especially VB6 .cls modules pretty much make it intact- with the help of the wizard -as the language did not change too much to VB.NET.

Otherwise if any of the following applies 1. its a typical LOB App with all the logic written inside form event handlers or 2. Uses proprietary OCX controls in its forms or 3. Uses a lot of Win32 API calls, subclassing, tricks.

then you would definitely benefit from rewriting.

Case in point. *VB6 app (circa 2001) using C1 + other Non Standard ocx controls *consisting of 60+files (28 forms , 25 .cls files , 8 .bas files plus change) *using the usual numerous Win32 calls (registry Shell etc.etc.)

Went through the upgrade wizard producing 1600+ issues. Of those only 15 were in class modules and all had relatively easy solutions (API replacement with .NET equivalent). The forms were were another story. Most custom controls had become labels! Totally unfixable given my time frame. End result. Kept the class modules in VB.NET and rewrote the UI in C#.

renick
+2  A: 

Converting the code from Visual Basic 6 to C# should best be done using an automated migration tool, like ArtinSoft's Visual Basic Upgrade Companion, which supports migration to C#.There are several reasons for this suggestion, aside from my experience with the tool.

First, even if you migrate from VB6 to VB.NET there are several language specific features in VB.NET that will not translate directly to C#. So even if you're using a VB.NET to C# converter you'll have to handle these special cases (or find a tool that handles them for you). These can include optional parameters, AddressOf fuctions, Visual Basic Compiler assisted operations, like Information.Err(), and Unstructure Error Handling to Structured Error Handling using Try / Catch statements. Another thing to consider is that the VB.NET compiler is limited to showing only 100 compilation errors, and compilation errors can be quite common when migrating. When moving to C#'s the compiler and other code analysis tools like ReSharper can give you a better picture of the challenge ahead, and help you detect common compilation error patterns.

Second, by migrating directly to the target language you can focus on using the features available for that language from the start, no intermediate steps. Otherwise, you'll basically end up doing two migrations when you could have focused on just one.

Third, as renick stated even though migration tools can produce hundreds or thousands of issues, most of these have relatively easy solutions. Some of them can be fixed using a find & replace function. Commercial solutions have the added advantage that they support the migration of third-party UI controls to .NET equivalents.

Also a migration can be much faster than a rewrite, you still have to write code but only for the areas where there are issues.

Granted there are applications for which a migration is not an option, but for those that fit the use case for a migration, it's a very effective means of switching platforms. You shouldn't discount the option right off the bat.

Migration Specialist
+1 Artinsoft are now offering a free license that can convert up to 10,000 lines of code http://www.artinsoft.com/artinsoft-renews-its-efforts-to-ease-the-transition-from-microsoft-visual-basic-6-to-microsoft-net-framework.aspx
MarkJ
A: 

Try ArtInSoft. This company will migrate your VB 6 code directly to C#.

KZoal
A: 

VBDepend can help to understand the existing vb6 code before migration, and accelerate the process during migration.

Issam