VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > VB.net教程 >
  • vb.net类型转换_将VB6转换为VB.NET

vb.net类型转换

VB.Net has a built-in migration tool, but converting VB6 code to VB.NET isn’t as easy as loading it to the newer software. The migration tool does a lot of the work, especially with syntax, but nowhere near all of it. You must work on your VB6 code before you try to load it in VB.Net.

VB.Net具有内置的迁移工具,但是将VB6代码转换为VB.NET并不像将其加载到较新的软件中那样容易。 迁移工具完成了大量工作,尤其是在语法方面,但远不及所有。 在尝试将其加载到VB.Net之前,必须先处理VB6代码。

您应该升级代码吗? ( Should You Upgrade the Code? )

Some types of programs are best left in VB6. If your projects use WebClasses, DHTML pages, and UserControls, the migration to VB.NET may not go smoothly. That isn’t to say you shouldn’t try. The migration wizard will list any critical issues, and you can go back and fix them.

某些类型的程序最好留在VB6中。 如果您的项目使用WebClasses,DHTML页面和UserControls,则向VB.NET的迁移可能不会顺利进行。 这并不是说您不应该尝试。 迁移向导将列出所有关键问题,您可以返回并修复它们。

准备要迁移的VB6代码 ( Preparing Your VB6 Code for Migration )

Remove any dead code that your program doesn’t use and join any duplicated code to reduce the code more. You can do this manually if you are patient or your program isn’t lengthy, or you can use a source code analyzer program to locate the duplicated or unused code.

删除程序不使用的任何无效代码,并加入任何重复的代码以进一步减少代码。 如果您有耐心或程序不冗长,可以手动执行此操作,也可以使用源代码分析器程序查找重复或未使用的代码。

修复任何数据声明 ( Fix Any Data Declarations )

If you used undeclared variables in your program, you have a lot of work ahead of you. Add proper type declarations to every Dim statement and add Option Explicit statements. This will smooth the import process. Don’t worry, if you miss any, you’ll find out later.

如果您在程序中使用了未声明的变量,那么您还有很多工作要做。 将适当的类型声明添加到每个Dim语句,并添加Option Explicit语句。 这样可以简化导入过程。 不用担心,如果您错过任何机会,都将在以后找到。

VB.NET向导开始工作 ( VB.NET Wizard Goes to Work )

Open your program in VB.NET and wait while the migration tool does its work. Expect to receive a lengthy report listing all the upgrade issues—the ones the wizard fixed and the ones it didn’t. There will also be comments in the code near spots that need extra work.

在VB.NET中打开程序,然后等待迁移工具完成其工作。 期望收到一份冗长的报告,列出所有升级问题-向导修复的问题和未解决的问题。 在需要额外工作的地方附近的代码中也会有注释。

尝试编译 ( Try to Compile )

Don’t even hope for your code to compile the first time through. It won’t, but you’ll receive a long list of compile errors that you can go back and fix.

甚至不希望您的代码在第一次编译通过。 不会,但是您会收到一长串的编译错误,可以返回并进行修复。

处理您的代码 ( Work on Your Code )

Using the reports, return to your code and fix the critical issues. When you’ve done them all, load the code into VB.NET again. You may receive another list of critical issues to fix, but eventually, it will make it through the wizard and the compiler. You’re not done yet. Look for comments the migration tool left in your code and do whatever the comments say.

使用报告,返回您的代码并解决关键问题。 完成所有操作后,再次将代码加载到VB.NET中。 您可能会收到另一个要修复的关键问题列表,但最终,它将通过向导和编译器完成。 您尚未完成。 查找代码中剩余的迁移工具的注释,然后执行注释中所说的任何操作。

Now, run and test your program in VB.NET. 

现在,在VB.NET中运行并测试您的程序。

翻译自: https://www.thoughtco.com/converting-vb6-to-vbnet-3974453


相关教程