.net 编译工具_VB.Net 教学(一)程序结构

ae3645f6fcbe60e2a16297bf119b8a9d.png

原文链接:VB.Net 教学(一)程序结构

在我们学习http://VB.Net编程语言的基本构建块之前,让我们看看一个最小的http://VB.Net程序结构,以便我们可以将它作为未来的章节的参考。

http://VB.Net Hello World示例

一个http://VB.Net程序主要由以下几部分组成:

  • 命名空间声明 Namespace declaration
  • 一个类或模块 A class or module
  • 一个或多个程序 One or more procedures
  • 变量 Variables
  • 主过程 The Main procedure
  • 语句和表达式 Statements & Expressions
  • 注释 Comments

让我们看一个简单的代码,打印单词“Hello World”:

Imports System
Module Module1
   'This program will display Hello World
   Sub Main()
      Console.WriteLine("Hello World")
      Console.ReadKey()
   End Sub
End Module

当上述代码被编译和执行时,它产生了以下结果:

Hello, World!

让我们来看看上面的程序中的各个部分:

  • 程序Imports System的第一行用于在程序中包括系统命名空间。The first line of the program Imports System is used to include the System namespace in the program.
  • 下一行有一个Module声明,模块Module1。http://VB.Net是完全面向对象的,所以每个程序必须包含一个类的模块,该类包含您的程序使用的数据和过程。The next line has a Module declaration, the module Module1. http://VB.Net is completely object oriented, so every program must contain a module of a class that contains the data and procedures that your program uses.
  • 类或模块通常将包含多个过程。过程包含可执行代码,或者换句话说,它们定义了类的行为。过程可以是以下任何一种:
    • 功能 Function
    • 子 Sub
    • 运算符 Operator
    • 获取 Get
    • 组 Set
    • AddHandler
    • RemoveHandler
    • 的RaiseEvent
  • 下一行('这个程序)将被编译器忽略,并且已经在程序中添加了额外的注释。
  • 下一行定义了Main过程,它是所有http://VB.Net程序的入口点。Main过程说明了模块或类在执行时将做什么。
  • Main过程使用语句指定其行为Console.WriteLine(“Hello World”的)
    WriteLine是在System命名空间中定义的Console类的一个方法。 此语句会导致消息"Hello,World !"在屏幕上显示。
  • 最后一行Console.ReadKey()是用于http://VS.NET用户的。这将阻止屏幕从Visual Studio .NET启动时快速运行和关闭。

编译和执行http://VB.Net程序:

如果您使用Visual http://Studio.Net IDE,请执行以下步骤:

  • 启动Visual Studio。Start Visual Studio.
  • 在菜单栏,选择文件,新建,项目。On the menu bar, choose File, New, Project.
  • 从模板中选择Visual Basic。Choose Visual Basic from templates
  • 选择控制台应用程序。Choose Console Application.
  • 使用浏览按钮指定项目的名称和位置,然后选择确定按钮。Specify a name and location for your project using the Browse button, and then choose the OK button.
  • 新项目显示在解决方案资源管理器中。The new project appears in Solution Explorer.
  • 在代码编辑器中编写代码。Write code in the Code Editor.
  • 单击运行按钮或F5键运行项目。将出现一个包含行Hello World的命令提示符窗口。Click the Run button or the F5 key to run the project. A Command Prompt window appears that contains the line Hello World.

您可以使用命令行而不是Visual Studio IDE编译http://VB.Net程序:

  • 打开文本编辑器,并添加上述代码。Open a text editor and add the above mentioned code.
  • 将文件另存为helloworld.vb。 Save the file as helloworld.vb
  • 打开命令提示符工具并转到保存文件的目录。Open the command prompt tool and go to the directory where you saved the file.
  • 类型VBC helloworld.vb,然后按回车编译代码。Type vbc helloworld.vb and press enter to compile your code.
  • 如果在你的代码中没有错误命令提示符下会带你到下一行,并会产生HelloWorld.exe的可执行文件。If there are no errors in your code the command prompt will take you to the next line and would generate helloworld.exe executable file.
  • 接下来,输入的HelloWorld来执行你的程序。Next, type helloworld to execute your program.
  • 您将可以看到“Hello World”字样在屏幕上。You will be able to see "Hello World" printed on the screen.
编译工具(VB Decompiler Pro):是一款针对使用Visual Basic 5.0/6.0开发的程序的反编译器。反编译工具(VB Decompiler Pro)可以被编译成伪代码p-code或native code模式。由于伪代码是由高级指令组成, 因此是很有可能反编译成源代码的(当然, 变量名,函数名等等是无法反编译的).反编译工具(VB Decompiler Pro)可以恢复众多伪代码指令,但要反编译成源代码还是有很多工作需要完成, 反编译器将帮助您更轻松的分析程序算法以及部分恢复源代码。 如果一个程序被编译成native code, 从机器码恢复源代码是几乎不可能的. 但即便是这种情形下VB Decompiler还是可以帮助你分析程序. VB Decompiler包含了一个强大的支持包含MMX和SSE的Pentium Pro指令集的反编译器. 它还包含一个代码分析器, 用于搜索所有API调用,汇编代码中的字符串引用并将结果修改为相应的注释。 加入一个程序被编译.net汇编,反编译器将恢复所有的托管代码的数据表和模块,并且使用IL反汇编器反汇编所有的方法,函数以及事件。反编译并不需要.NET Framework并且支持所有的32位Windows操作系统。 VB Decompiler也将反编译文件中的所有的图形界面窗体以及控件。出于技术需要,反编译器可能显示所有控件的编译地址。 对于加壳的VB程序,首先需要脱壳后才能正常反编译。 总而言之, VB Decompiler是一款出色的程序分析工具. 尤其是当您不慎丢失源代码并且需要部分恢复原工程的时候。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值