5

We have a client who wants to convert a bunch of VB6 projects in to VC++ native code. I would like to know if there are any tools available for such conversion.

We tried http://vbto.net/, which converts, but generates tons of compile errors. The tool creates all cpp projects as "exe", while many of the source VB6 projects are "activex dll".

How does a VB6 project map to a VC++ project? For e.g., does a "activex dll" map to vc++ ATL project? What are the things we should look out for? If you can share your experience, we will greatly appreciate it.

(yes, our first response was to suggest conversion to VB.NET/C#, but the program needs to run on machines that won't have .NET framework installed, and also invokes methods in kernel32.dll)

Shankar
  • 1,634
  • 1
  • 18
  • 23
  • 1
    Why convert to C++? What's the benefit? By the way, .Net framework is installed as part of Windows on recent versions, and you can call Kernel32 from .Net via Pinvoke. Although it's very likely that you cam achieve the same effect in pure .Net without calling Kernel32. – MarkJ Oct 14 '10 at 20:25
  • 1
    Why convert at all? If you can't justify a rewrite the current program ought to be fine. A VB6 project of any size converted using automatic tools will be a bear to maintain. – Bob77 Oct 18 '10 at 00:59
  • 1
    we did end up using vbto.net and fixing the compiler errors manually. it was difficult, but we managed to successfully port the code. the complete rewrite was not an option for us because, the new system under which the application ran did not have any .net runtime or visual basic dlls installed. – Shankar Aug 17 '12 at 18:38

2 Answers2

0

You might consider using a migration tool that is capable of handling the complete conversion. See What kinds of patterns could I enforce on the code to make it easier to translate to another programming language?.

The DMS engine involved has full parsers for VB6 and Visual C++, and can apply transformation rules that map VB6 surface syntax to Visual C++ surface syntax.

Somebody has to write the translation rules, and there's a lot of them to write; you need one for each langauge construct and context in which it can occur. This means in your case that you'd need special rules to produce a translation as a DLL rather than .exe, if that's a real requirement. Writing such rules is harder than it it looks mostly becuase of the number you need to write, usually on the order a 1000-2000; this isn't for the faint of heart. But it can produce very reliable translators (read the answer at the link for more details).

You didn't say what "a bunch of code" was. At smaller scales, you can use more ad hoc approaches (hand translation, patching the output of a bad translator [e.g., the one you discussed], etc). At sufficient scale the automated conversion is an effective approach.

Community
  • 1
  • 1
Ira Baxter
  • 93,541
  • 22
  • 172
  • 341
  • this is probably the most reliable solution, but as you say this is not for the faint of heart. we didn't use this one. we went with vbto.net and fixed all the compiler errors manually. – Shankar Aug 17 '12 at 18:36
  • So how much code did you convert using vbto.net? How much went through and was converted correctly? How long did it take you fix the rest? – Ira Baxter Aug 18 '12 at 23:55
-1

you can't. maybe you can convert vb6 code to vb.net. then you can easyly convert it to c# or managed c++ (all .net langs compiles to msil so can be tranformed to another .net lang easyly with reflector, etc..)

sirmak
  • 3,749
  • 4
  • 30
  • 34
  • converting to managed code (vb.net, c# or managed c++ or any other) is not an option, .net framework is not available on the target machines. – Shankar Oct 12 '10 at 22:14
  • try http://www.tangiblesoftwaresolutions.com/Product_Details/VB_to_CPlusPlus_Converter_Details.html – sirmak Oct 12 '10 at 22:19
  • your link takes me to a VB.NET to C++ converter. I'm looking for VB6 to VC++ converter. – Shankar Oct 13 '10 at 05:02
  • you're right. they say upgrade vb6 to vb.net with their migration tool and then use vb.net to c++ tool. I think the only possibilty left is full rewrite. – sirmak Oct 13 '10 at 12:40
  • Full manual rewrites tend to failure as the code base size goes up. People that say "doing a manual rewrite is your only option" often haven't tried to do this. – Ira Baxter Aug 18 '12 at 23:48