I am looking for a utility/tool to convert calls to legacy VB6 functions to the .NET equivalent.
For example, it would convert this...
FormatCurrency(Cart.TotalAmount)
Len(Str)
UCase(Str)
UBound(PaymentsArray)
To this...
Cart.TotalAmount.ToString("c")
Str.Length
Str.ToUpper()
PaymentsArray.Length - 1
Does anybody know of one, or am I going to have to roll my own?
Do you need a conversion for those functions? The vb6 functions work just fine in vb.net.
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