【VB/.NET】Converting VB6 to VB.NET 【Part I】【之二】

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

第二部分


原文:

VB6 and ActiveX Controls

Most of the basic VB6 controls will be upgraded by the wizard without any issues,as will many advanced and third-party controls. Even complex ActiveX controls like the MSChart and third party controls are likely to convert with only minor changes in Syntax. For instance,the MSChart control converts and mostly behaves like the original. The biggest difference is that the Axis is accessed as a property in VB6,but this is done by using an accessor in VB.NET. For example,in VB6 the XAxis maximum value is set by the statement:

MSChart1.Plot.Axis(VtChAxisIdY,0).ValueScale.Maximum = 370

In VB.NET,it is set by the statement:

MSChart1.Plot.get_Axis(VtChAxisIdY,0).ValueScale.Maximum = 370;

As far as I can tell,this is the only property of MSChart that is treated with this minor difference. The wizard will automatically create a wrapper for any ActiveX controls used in the project. You can also create a wrapper for any ActiveX control you want to use in a .NET program by simply right-clicking on the toolBox,selecting add/remove items,and then choosing the ActiveX control from the COM tab of the Dialog Box. This task can also be accomplished by running the TlbImp.exe utility that comes with the free .NET SDK. One small difference: an "upgraded" ActiveX control is referred to by its original name when referenced in the program,but an ActiveX control added to a new .NET project gets an "ax" prefix. For instance,when upgraded from a VB6 project,MSChart stays MSChart; when added to a .NET project,it becomes axMSChart.

While complex components and ActiveX controls are moved to .NET via the use of wrappers,basic VB6 controls are upgraded to (replaced by) VB.NET controls.


译文

VB6及其Active控件

大多数基本的VB6控件在向导的帮助下都会被毫无问题的升级,一些先进的第三方控件也是这样的。甚至是像MSChart以及其它的第三方的ActiveX控件在转换的时候很可能只存在语法上的轻微变化。例如前面所说的MSChart转换之后大多数的功能特性都和原来一样。但是最大的区别就是坐标的问题,在VB6里它是作为一个属性链接的,但是在VB.NET中是通过一个连接器(Accessor)。例如: 在VB6中XAxis最大值通过如下的语句来设置: MSChart1.Plot.Axis(VtChAxisIdY,0).ValueScale.Maximum = 370 同时,在VB.NET中,应该这样做: MSChart1.Plot.get_Axis(VtChAxisIdY,0).ValueScale.Maximum = 370 正如我所说的,这就是MSChart上唯一一个关于我所说的微小差别的属性。我们的向导会为项目中使用过的AX控件自动创建一个包装类。同样你也可以自己创建一个包装类(为任何你想要在一个.NET程序中使用的AX控件),通过这样的方法:右击工具箱(ToolBox)->选择“添加/移除项目(Add/Remove items)”->从COM选项卡对话框中选择AX控件。这个任务你也可以通过使用.NET SDK附带的Tlbimp.exe实用工具来完成。同时又这么一个小区别:通过“升级”的来的AX控件使用原来的名字被引用,但是作为一个AX控件被添加进一个.NET新项目会被冠之以"ax"作为前缀。例如,当从VB6项目升级后,NSChart使用MSChart的名字,然而被添加进.NET项目的变成了axMSChart。 虽然复杂的组件和AX控件通过类包装移植到.NET,但是基本的VB6控件以替换的形式来升级

猜你在找的VB相关文章