VB 到 C# 或 VB.net 转换

发布于 2024-09-08 20:40:03 字数 333 浏览 3 评论 0原文

我有一个VB应用程序。客户希望将其转换为 .net 应用程序。我想继续将其转换为 C# Windows 应用程序。但我不确定我将面临的挑战。

一种方法是只了解 VB 代码并用 C# 或 VB .net 重写所有模块。

另一种我不知道的方法是基于工具的转换。

我可以知道您将如何进行这种转变吗?您更喜欢哪种类型的工具来进行转换以及您可能面临的挑战?

为了简单起见,我们假设我们要将一个简单的 VB 转换为 VB .net 或 c# windows 应用程序。

您更喜欢 VB 到 VB.net 的转换还是 VB 到 C# 的转换。即使您可以部分回答这个问题,我也将不胜感激。

I have a VB application. Clients wanted to convert that to a .net application. I would like to go ahead and convert that to C# windows application. But I am not sure on challenges that I will be facing.

One method is to just understand the VB code and rewrite all the modules in C# or VB .net

The other way that I am not aware of is the tool based conversion.

May I know how you would approach with such conversion? What type of tools you would prefer for conversion and challenges that you might face?

For simplicity lets assume that we are going to convert a simple VB to a VB .net or c# windows application.

Would you prefer VB to VB.net conversion or VB to C# conversion. Even if you can answer this question in parts I would appreciate it.

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

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

发布评论

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

评论(8

白昼 2024-09-15 20:40:04

有许多在线代码转换器可用于简单地转换语法。一些示例是:

这些转换器不会处理所有问题。例如,数组访问在 VB 中使用 (),与方法访问器相同,而在 C# 中则使用 []。这会带来一个问题,因为转换器不知道哪些是方法,哪些是数组。

显然,最大的问题是旧版 VB 和 .NET 之间的差异。即使您进行了翻译,您也可能会遇到许多有关过时、不推荐使用的方法、限制等的问题。

我建议在使用代码转换器之前重新评估您的应用程序,以便您了解会发生哪些变化。

There are many online code converters out there for simply converting syntax. Some examples are:

These converters will not take care of all the issues. For examples, arrays access is with () in VB, same as method accessor, whereas it is [] in C#. This poses a problem because the converters do not know which are methods and which are arrays.

Obviously, the biggest problem is the differences between old VB and .NET. Even if you do translate, you will likely fall into many problems regarding obsolete deprecated methods, constrictions, etc.

I would suggest to re-evaluate your application before using code converters so that you have an idea of what changes to expect.

中性美 2024-09-15 20:40:04

只是一篇博客文章,其中包含有关从 VB6 迁移到 VB.NET 和 C# 的一些建议:

VB6 到 VB.Net升级版升级帮助 – 是的,您并不孤单(在您的 VB6'ness 中)...

Just a blog post with some pointers regarding migration from VB6 to VB.NET and C#:

VB6 to VB.Net Upgraded Upgrade Help – Yes, you are not alone (in your VB6’ness)…

み青杉依旧 2024-09-15 20:40:04

我会选择 C#,因为我更喜欢这种语法。我认为你应该选择你最熟悉的语言。

我曾经使用过 .Net 之前的 VB,并且完成了一些 VB.Net 编码,但是这两种语言之间的相似之处不足以指导我做出这样的选择。

无论如何,它可能更多的是重写而不是移植,因为在 GUI、数据库、文件访问等方面存在许多技术差异。

我希望您现有的产品结构良好,这将在此过程中有所帮助。如果不是,那么在移植/重写之前花时间重构或重组(无论你怎么称呼它)都是值得的。

I would choose C# because I am more comfortable with that syntax. I think you should choose the language you're most at home with.

I used to work with pre .Net VB, and I have done some VB.Net coding, but the similarities between those two languages are not big enough to direct that choice.

In any case, it will probably be more of a rewrite than a port because there are many technological differences in GUI, DB, file access, and so on.

I hope your existing product is structured well, it will help in the process. If it's not, it can well worth the time to refactor or restructure (call it what you will) before porting/rewriting.

丢了幸福的猪 2024-09-15 20:40:04

在开始之前:
VB 不是面向对象语言...C# 和 VB.NET 是!
至关重要的是,您必须在头脑中深深地了解这一点:面向对象开发与过程式编程完全不同。您可以使您的新系统代码看起来像您当前的系统代码 - 但您确实不应该这样做。如果您不想学习面向对象并改变应用程序的运行方式,那么您不应该开始这个项目,因为您会浪费时间和金钱,并且可能会失败。
...毕竟你不能将笔浸入墨水中以重新填充它 - 旧方法很有趣,但技术的出现是有原因的。
但我不确定我将面临的挑战。
....你应该学习面向对象。之后,通过正确的问题,将很容易获得答案 VB 不再受 Microsoft 支持,您不应该落后,尤其是当客户要求您移动它时。这并不容易——但你别无选择。

一种方法是只了解 VB 代码并用 C# 或 VB .net 重写所有模块
....这是唯一的方法 - 当事情开始崩溃时 - 你不会指责转换器 - 你有责任理解系统中的每个功能

我不知道的另一种方法是基于工具的转换。
...其他人为您提供了工具 - 它对语法有好处,但对整体功能有风险

我可以知道您将如何进行这种转换吗?您更喜欢哪种类型的工具来进行转换以及您可能面临的挑战?
...使用 Visio word excel 或更专业的工具(如 UML 图表应用程序)映射您的函数

为简单起见,我们假设我们要将简单的 VB 转换为 VB .net 或 c# windows 应用程序。
...构建表单很容易,组件通常更强大,

您更喜欢 VB 到 VB.net 转换还是 VB 到 C# 转换。
...选择C# vb让人觉得他们还在vb环境中...C#让你明白你处于一个不同的世界。然而,重要的是您要知道 Microsoft 决定调整这两种语言以具有相同的功能。

有很好的从一种语言到另一种语言的转换器。

Before I start:
VB is not an object oriented language ... C# and VB.NET are!
It's crucial that you bare this deep in your mind - developing object oriented is nothing like procedural programming. You can make your new system CODE look like your current - but you really shouldn't. If you don't feel like learning Object Oriented and change the way your application goes you should not start this project because you'll waste time and money and probably will fail.
...After all you don't dip your pen in ink well to refill it- old methods are interesting but technology is here for a reason.
But I am not sure on challenges that I will be facing.
....You should learn object oriented. After that with the right questions it will be easy to get answers VB is no longer supported by Microsoft and you should not stay behind especially when the customers ask you to move it. It won't be easy - but you don't have a choice.

One method is to just understand the VB code and rewrite all the modules in C# or VB .net
....This is the only way - when things will start falling apart - you will not accuse the convertor - you are responsible to understand every function in your system

The other way that I am not aware of is the tool based conversion.
...others offered you tools - its good for syntax but risky for overall functionality

May I know how you would approach with such conversion? What type of tools you would prefer for conversion and challenges that you might face?
...map your functions with Visio word excel or more professional tools like UML diagram applications

For simplicity lets assume that we are going to convert a simple VB to a VB .net or c# windows application.
...building the forms is easy the components are usually more powerful

Would you prefer VB to VB.net conversion or VB to C# conversion.
... Choose C# vb make people think they are still in a vb environment... C# makes you understand you are in a different world. Yet it is important that you will know that Microsoft decided to align the two languages to have the same functionality.

There are good convertors from one language to the other.

冷情妓 2024-09-15 20:40:04

根据我的经验,最好的方法就是重写应用程序。

每次我尝试使用自动转换器时,它都惨遭失败。 VB 中有很多东西不能很好地转换(比如控制数组)。

In my experience, the best way to do this is to just rewrite the application.

Every time I tried to use an automated converter it failed miserably. There are many things in VB that just don't translate well (like control arrays).

诗笺 2024-09-15 20:40:04

这取决于 - 您的应用程序的大小、您的应用程序的 GUI 和非 GUI 部分的大小、您的应用程序使用的外部库/组件以及您或您的团队更喜欢哪种语言(C# 或 VB.NET) 。

如果您可以在旧的 VB 应用程序中隔离大量非 GUI 代码,那么“VB 到 VB.NET”之路通常可能是更好的选择,因为您可以使用以下命令移植大量旧代码的机会并不坏:只有微小的变化。在所有其他情况下,C# 或 VB.NET 对于此目的几乎是相同的,因此请选择您团队中最有经验/最现有代码/最专业知识的语言。

It depends - on size of your application, on size of the GUI and non-GUI parts of your application, the external libraries/components your application uses and also which language (C# or VB.NET) you or your team feels more comfortable with.

If you can isolate a lot of non-GUI code in your old VB application, the "VB to VB.NET" road may often be the preferable one, because the chances are not bad that you can port a lot of your old code with only minor changes. In all other cases, C# or VB.NET are almost equal for this purpose, so choose the language you have most experience / most existing code / most know-how in your team.

千紇 2024-09-15 20:40:04

最好的方法是重写应用程序。我认为使用 vb.NET 更好,因为语法与 vb 类似。如果您想尝试转换工具,我建议您使用 VB Migration Partner。 www.vbmigration.com

The best way is to rewrite application. I think is better to use vb.NET because syntax is similar to vb. If you want to try a conversion tool I suggest VB Migration Partner. www.vbmigration.com

抱猫软卧 2024-09-15 20:40:03

您可以看一下这篇文章,作为热身,值得一读:Converting VB6 to VB .NET,第一部分

我的建议是只翻译用户实际使用的部分,根据他/她的需求添加新功能。

You could to take a look into this article, it's worth reading as a warm up: Converting VB6 to VB.NET, Part I

My advice is to translate just pieces your user actually uses, adding new features as he/she demands.

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