【VB/.NET】Converting VB6 to VB.NET 【Part II】【之一】

前端之家收集整理的这篇文章主要介绍了【VB/.NET】Converting VB6 to VB.NET 【Part II】【之一】前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

第一部分

原文:

Last month (Vol. 2,issue 9),I gave an executive overview of the conversion process,and started looking at converting general VB6 code to VB.NET. This month I will finish general conversions,including DLLs,then start on database conversions. Next month,in the final segment,I will cover converting ASP.NET Web pages,and look at converting to VB.NET 2005 and C#.


Nothing Is Perfect

After the conversion wizard is done,the upgrade report will probably contain a list of many issues. A lot of these issues are minor things that nothing can be done about,but which in most cases will have little impact on the final program. For instance,if you use the ZOrder property in VB6,the wizard will convert it,but add a message that the behavior has changed. All of the issues flagged by the wizard will have a link to a URL explaining the problem. In the case of ZOrder,the difference between the VB6 behavior and the VB.NET behavior is in that in VB6 the form is brought to the front of the application; in VB.NET the application is also brought to the front of all other applications running on the computer. In most cases this is closer to the desired result than in the VB6 behavior.
The Dir command is another example. In VB6,using the Dir command to list the files in a directory always listed the "." and ".." first in the returned file list,the DIR command would always list them first. In VB.NET,"." and ".." are never listed in the Dir results. These were not always listed in VB6 - for instance,they are not part of the root "\" directory - so correct VB6 code checks for these directories. Such code will perform correctly in VB.NET. However,some VB6 programs just ignore the first two files returned by Dir,assuming they are "." and ".."; this code will always miss the first two files in VB.NET,and in some cases in VB6. This is another example of well-written code converting well.


译文:

上个月(卷2,第9期),我大概的描述了转换过程的流程,并开始关注了普遍的VB6到VB.NET的代码。这个月我将会更将丰富完成普遍的转换,包括DLLs,接着会关注数据库的转换,其次就是转换到ASP.NET网页并开始关注了VB.NET2005和C#。

没有什么是完美的

在转换向导结束之后,升级报告可能会将许多问题列出来。许多这些问题都是小问题,都是升级向导所解决不了的,但是这些问题里大多数情况下都不会对最终的程序产生什么影响。比如说,如果在VB6中使用了ZOrder属性,但是向导转换了代码之后还添加了个信息,这就意味着对象行为发生了改变。所有由向导标记的问题将由URL链接导向到相关说明。在前面所提到的ZOrder问题中,VB6和VB.NET之间的行为区别在于VB6中的窗体被展现在程序(一个程序可以有多个窗体)的最前端,然而VB.NET也会这样做,但同时还被展现在左右在电脑里运行的其它程序前。大多数情况下,这样做比VB6会更接近程序员所期待的效果

另一个例子是关于Dir命令的。在6中,使用这个来列出目录中的文件时总是会先列出"."和"..",而VB.NET中这两个东西将不再在返回列表中出现。但是也并不总是在VB6中被列出来,比如当他们不属于根目录"\"时,所以正确的VB6代码会检查这些目录的,这样的代码在VB.NET中会正确地执行。但是,一些VB6程序会将返回列表假设为"."和".."开头(实际上是真实存在的文件),然后仅仅是简单的忽略了Dir返回的前两个结果,这样子移植后的代码在VB.NET中总是会丢失这前两个文件,这在VB6中的一些案例同样会出现这样的情况。这也是 “well-written code converting well”(写得好转换得也好)的另一个例子。


Update Log:

2014-5-17 16:51 原文链接:https://www.f2er.com/vb/259010.html

猜你在找的VB相关文章