将 .bas 文件移植到 vb.net
我正在处理一些旧版 VB5/VB6 代码,需要将“.bas”文件转换为 vb.net。
我找到了几个选项
将.bas文件编译成com dll,然后在我的项目中引用和使用它。 (为此,我想我需要 vb5 或 vb6,但我没有可用的)
将文件内容复制并粘贴到 vb.net 中的新模块中,然后尝试一一解决错误.
.bas 文件的内容引用特定的 dll。 .bas 文件主要包含 consts、类型、sub 和函数的声明。
在 vb.net 中重做此操作的最优雅的方法是什么?是否像选项 2 一样简单。
编辑
我使用 VS2008 Express 并通过升级向导运行代码,它进行了必要的转换。并且 .bas 文件已转换为 .vb。我获取了该文件并决定重写代码的其他部分,包括对转换后的 .vb 文件进行一些重做。
与此相关的其他问题位于此处。
I'm working on some legacy VB5/VB6 code and need to convert a ".bas" file to vb.net.
I found several options
Compile the .bas file into a com dll and then reference and use it in my project. (For this I guess I would need vb5 or vb6 which I don't have at my disposal)
Copy and paste the contents of the file in to a new module in vb.net and then try solving the errors one by one.
The contents of the .bas file reference a particular dll.
The .bas file has mostly declarations consts, types, sub's and functions.
What would be the most elegant way of redoing this in vb.net. Is it as simple as option 2.
EDIT
I used VS2008 express and ran the code through the upgrade wizard it did the necessary conversion. and the .bas file was converted to .vb. I took that file and decided to rewrite other parts of the code, including some redoing of the converted .vb file.
Other questions related to this one are here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
考虑重写作为替代方案。根据我的经验,从长远来看,这比依赖不透明的 COM 库或使用 VB6 迁移向导并拾取它吐出的部分的工作量要少。
根据您对 .NET 的了解,重写单个 VB6 模块不会花费很长时间。如果您刚刚开始使用 .NET,那么这可能需要更长的时间,但它也将提供学习 .NET 的良好机会。
Consider rewriting as an alternative. In my experience, this makes less work in the long run than either relying on an opaque COM library or using the VB6 migration wizard and picking up the pieces it spits out.
Depending on your knowledge of .NET, the rewrite of a single VB6 module shouldn’t take very long. If you are freshly starting with .NET then this may take longer but it will also provide good opportunities to learn .NET.
Microsoft 提供了指南,说明如何操作,包括尝试将 VB6 代码转换为.NET
这包括您的两个解决方案,除了 2 个由转换器帮助之外。
这取决于 VB6 代码的复杂程度及其用途。
但是,如果您必须支持并更改 VB6 代码,那么现在可能值得进行转换。
Microsoft provide guidance on what to do including an app that attempts to convert VB6 code to .NET
This includes both your solutions except 2 is helped by the converter.
It depends on how complex the VB6 code and what it does.
However if you are going to have to support and change the VB6 code it would probably be worth doing the conversion now.
转换为 vb.net 有很多优点——与未来(也可能是当前)系统的兼容性和可维护性是最重要的。将其保留为 dll 的主要优点是节省开发时间,但如果将来出现兼容性问题,这可能会适得其反。
如果代码现在位于 VB6 项目中,或者如果可以将其添加到其中,则可以使用 vb.net 打开 .vbp 项目文件,它会询问您是否要自动将其转换为 vb.net。它做得非常好,不包括第三方附加组件。
There are a lot of advantages to converting to vb.net -- compatibility with future (and possibly current) systems and maintainability being the most important. The main advantage to leaving it as a dll would be to save development time, but this could backfire if there are future compatibility problems.
If the code is in a VB6 project now, or if it can be added to one, you can open the .vbp project file with vb.net and it will it asks if you would like to automatically convert it to vb.net. It does a pretty good job, exclusive of third party add-ons.