• 【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.


    译文:

    上个月(Vol. 2, issue 9),我大概的描述了转换过程的流程,并开始关注了一般的VB6到VB.NET的代码。这个月我将会更将丰富完成一般的转换,包括DLLs,接着会关注数据库的转换,然后就是转换到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》(《写得好转换得也好》)的另一个例子。


  • 相关阅读:
    个人技术博客(α)------javaweb的学习路程
    使用github客户端上传文件(瓜皮教程)
    软件工程实践 : 团队项目(第三次作业) 需求规格说明书
    软件工程实践 · 团队项目(第二次作业)
    软件工程实践:结对作业(第二次作业)
    软件工程实践:结对作业(第一次作业)
    软件工程实践 · 团队项目(第一次作业)
    班级连接
    软件工程 第二次作业(改)
    Shader Forge 刀光溶解
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3026965.html
Copyright © 2020-2023  润新知