Utility to Convert Legacy VB6 Function Calls to .NET [closed]

浪子不回头ぞ 提交于 2019-12-02 01:10:33

Do you need a conversion for those functions? The vb6 functions work just fine in vb.net.

MarkJ

If your code is already converted to working VB.Net, why not just leave the calls as they are? The routines are in Microsoft.VisualBasic.dll which is a fully supported part of the .NET framework and will be around as long as .NET is around. Avoid using them in new code if you like, but doing extra work to take them out of existing code seems rather unecessary.

If you haven't yet converted the code, you could choose to buy Artinsoft's VB Upgrade Companion which can do some of the conversions you ask for, as part of the VB6 to VB.Net conversion.

With gmStudio, the VB6/ASP/COM analysis and re-engineering tool from Great Migrations, you can control these things by changing the 'surface forms' used by the 'string machine' as it interprets the pcode generated by its compiler and authors it in the desired notation. For example, here are the default surface forms for Len:

  <subcode id="Len">
     <vbn role="function" narg="1" code="Strings.Len(%1d)"/>
     <csh role="function" narg="1" code="VBNET.Strings.Len(%1d)"/>
  </subcode>

To customize the C# code emitted for the Len operation you can apply an override and create a custom translation configuration:

  <subcode id="Len">
     <csh role="function" narg="1" code="%1d.Length"/>
  </subcode>

The placeholder %1d indicates where the original parameter should be emitted into the C# code stream.

This is a simplification of a very simple case, but that's the idea.

NOTE: the default surface forms are closer to the original semantics of VB6. For example string.Length throws an exception in C# if the argument is null, but VBNET.Strings.Len() returns 0. That said, if you never expect a null string then throwing an exception when one occurs might be advantageous -- or not -- at least you have the choice.

There is a free migration tool from Microsoft available here. It was released when VS2003 was released.

You get it here: http://blogs.msdn.com/b/bethmassi/archive/2010/07/08/free-vb6-migration-tool-amp-updated-vb-developer-center.aspx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!