将旧版 VB6 函数调用转换为 .NET 的实用程序

发布于 2024-08-17 14:39:21 字数 318 浏览 3 评论 0原文

我正在寻找一个实用程序/工具,将对遗留 VB6 函数的调用转换为 .NET 等效函数。

例如,它将把这个……转换

FormatCurrency(Cart.TotalAmount)
Len(Str)
UCase(Str)
UBound(PaymentsArray)

成这个……

Cart.TotalAmount.ToString("c")
Str.Length
Str.ToUpper()
PaymentsArray.Length - 1

有人知道吗,还是我必须自己动手?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

狼性发作 2024-08-24 14:39:21

您需要对这些功能进行转换吗? vb6 函数在 vb.net 中工作得很好。

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

我偏爱纯白色 2024-08-24 14:39:21

如果您的代码已经转换为工作 VB.Net,为什么不直接保留调用原样呢?这些例程位于 Microsoft.VisualBasic.dll 中,它是 完全支持的部分.NET 框架,只要 .NET 存在,它就会存在。如果您愿意,请避免在新代码中使用它们,但做额外的工作将它们从现有代码中取出似乎是不必要的。

如果您还没有转换代码,您可以选择购买 Artinsoft 的 VB 升级伴侣,可以执行您要求的一些转换,作为 VB6 到 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.

情丝乱 2024-08-24 14:39:21

使用来自 Great Migrations 的 VB6/ASP/COM 分析和重新设计工具 gmStudio,您可以通过更改“字符串机器”使用的“表面形式”来控制这些事情,因为它解释由编译器生成的 pcode 并编写它以所需的符号表示。例如,以下是 Len 的默认表面形式:

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

要自定义为 Len 操作发出的 C# 代码,您可以应用覆盖并创建自定义翻译配置:

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

占位符 %1d 指示应将原始参数发出到 C# 代码中的位置溪流。

这是一个非常简单的案例的简化,但这就是想法。

注意:默认的表面形式更接近VB6的原始语义。例如,如果参数为 null,则 string.Length 在 C# 中引发异常,但 VBNET.Strings.Len() 返回 0。也就是说,如果您从不期望出现空字符串,那么在出现异常时抛出异常可能会更有利——或者不——至少你有选择。

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.

调妓 2024-08-24 14:39:21

此处提供了 Microsoft 的免费迁移工具。它是在VS2003发布时发布的。

您可以在此处获取它:http://blogs.msdn.com/b/bethmassi/archive/2010/07/08/free-vb6-migration-tool-amp-updated-vb-developer-center.aspx< /a>

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文