6

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

Jon Seigel
  • 12,251
  • 8
  • 58
  • 92
odiseh
  • 25,407
  • 33
  • 108
  • 151
  • I almost said rewrite it, but I suppose the answers are better. However, migrating an app often does not seem to bring any advantage towards writing it new, but I suppose it depends on the size. – flq Feb 03 '10 at 11:20

6 Answers6

9

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.

Amirshk
  • 8,170
  • 2
  • 35
  • 64
  • you have to add some more aspects into your argumentation. Sometimes it is not possible to write from scratch, because the application makes its business well or you do not want to maintain/manage two applications parallel (VB6 + .NET). I am involved in enterprise application (approximately 100.000 lines of code) where we migrating step by step from VB6 to C# using Artinsoft. It would not been possible to support the VB6 and rewrite from scratch at the same time, because of the amount of available programmers (money). – Rookian Mar 31 '11 at 19:18
8

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.

Community
  • 1
  • 1
Shoban
  • 22,920
  • 8
  • 63
  • 107
4

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 functions, 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.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
  • +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 Jul 20 '10 at 08:38
1

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
  • 632
  • 4
  • 7
1

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
  • 5,636
  • 7
  • 38
  • 58
0

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

KZoal
  • 64
  • 2