VB6 code upgrade [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 13:28:05

Don't do it. Don't convert. Do a re-write. Sorry, but even though the code CAN be converted, it doesn't mean it should be converted.

Please, in the name of cleaner code everywhere, spend the resource time to have it written correctly. View this as an opportunity to clean up the code, and take advantage of everything .Net brings to the table....

And I really don't care if I get negative rep'd on this one. If I convince one company to rewrite instead of convert, it was worth it.

MarkJ

This is a copy of my answer to the duplicate question (as CW) because I want to reply to the "always rewrite" answer that's currently top-voted here.

My advice is don't underestimate the effort of conversion - be very cautious about embarking on a rewrite. It's a common pitfall to start out optimistically, make good early progress fixing some of the well-known flaws in the old architecture, and then get bogged down in the functionality that you've just been taking for granted for years. At this point your management begin to get twitchy and everything can get very uncomfortable.

...and here's a blog post by a Microsofty that somewhat agrees with me:

Many companies I worked with in the early days of .NET looked first at rewriting driven in part by a strong desire to improve the underlying architecture and code structures at the same time as they moved to .NET. Unfortunately many of those projects ran into difficulty and several were never completed. The problem they were trying to solve was too large .....

Hence I quickly became a fan of Migrate or Reuse as the right approach for most companies. Interestingly though, Rewrite is a less risky option than it once was. Many companies who still have significant VB6 projects also now have strong .NET skills gained on other projects, improved software development practices (including automated tests – a must IMHO for Rewrite) and have even taken the time to refactor elements of their VB6 codebase over the last 6 years. That said, I would still place Rewrite below Migrate or Reuse for most companies.

Quote from an excellent Microsoft webpage

Performing a complete rewrite to .NET is far more costly and difficult to do well [than converting] ... we would only recommend this approach for a small number of situations.

Also the renowned VB expert Dan Appleman said:

In most cases porting [VB6 to VB.NET] is stupid and a complete waste of money.

And Joel said a while back:

The single worst strategic mistake that any software company can make [is to] decide to rewrite the code from scratch.

A couple of other useful links about migration including links to another free book from Microsoft. One. Two. Three.
Microsoft page including screencast with their answer to "how to migrate"

Just about any free tool will do a decent job of converting the code. The result that you get is not really good whatever tool you use, because VB.NET code is quite different from VB6 code, despite the syntax similarities. Even if you use a translation tool, you should make a thorough cleanup of the code.

Visual Studio has an integrated conversion tool in menu File > Open > Convert....

If your VB6 project is well structured and well commented and you are an expert in both languages (VB6 and VB.NET), you can give it a try, otherwise the conversion could become a nightmare. In any case you will have to fix many things manually after the conversion.


Googling Language Changes for Visual Basic 6.0 Users will give you useful links covering the differences between the two languages.

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