views:

103

answers:

3

Visual Studio comes with Wizard that converts vb6 code to vb.net. Is there are any way to call this conversion via code?

+2  A: 

No this not accessible from code. This process is largely driven by a command line tool and doesn't have a public facing API (that I'm aware of at least).

Can you help us understand how you plan on using this?

JaredPar
To make migration smooth, will be required to support both applications. Currently what I am doing is manual copy and paste portion of a code from vb6 into vb.net using Visual Studio. That allows to make initial code conversion properly. I would like to automate this process.
volody
The only feature I need is "Pretty listing (reformatting) of code"
volody
+1  A: 

To be honest, when updating from VB6 to .NET it is much better to do it manually, this way you can improve the solution and not rely on 3rd party tools that may not convert the way you want to.

kyndigs
Gotta agree with kyndigs here. You're going to be missing out on tons of refactoring opportunities and ways to leverage .net if you attempt an automated conversion. In the end, automating may get you a result faster, but it'll cost you in the long run.
drventure
A: 

"Pretty listing (reformatting) of code" could be accomplished by next code based on How to: Fix 'Application is Busy' and 'Call was Rejected By Callee' Errors

// =====================================
// ==Insert your automation code here.==
// =====================================
Command cmd = dte.Commands.Item("Edit.Paste", -1);
object dummy = new object();
foreach (var item in Directory.EnumerateFiles(codefolder))
{
    dte.ItemOperations.OpenFile(PathToEmptyVbFile);
    Clipboard.SetText(System.IO.File.ReadAllText(item));
    System.Threading.Thread.Sleep(500); // to enable vs paste button
    dte.Commands.Raise(cmd.Guid, cmd.ID, ref dummy, ref dummy);
    dte.ActiveDocument.Save(item);
    dte.ActiveDocument.Close();
}
volody