Getting Started

I l @ ve RuBoard

In keeping with programming tradition, Listing C.1 outlines our first "Hello, world" program.

Listing C.1 The classic "hello, world" program, hello.vb.
 Imports System.WinForms Module Hello     Sub Main() {         ' write "Hello, world!" to the screen          MessageBox.Show("Hello, World!")     End Sub End Module 

By following convention, the source code for our program is saved with a .vb file extension, hello.vb . We can compile our program using the VB.NET command-line compiler, vbc.exe , using the following syntax:

 vbc hello.vb 

The output of this directive produces our executable program, hello.exe . The output of the program is

  Hello, World! 

From this basic example, we can glean several important points:

  • The entry point of a VB.NET program is a subroutine named Main .

  • You can write to the console using the System.WinForms.MessageBox class found in the .NET platform framework classes.

  • C, C++, and C# developers may notice that our Main is not enclosed within a class. In the example, Sub Main is found within Module Hello . Modules are a special reference type whose members are implicitly shared. Modules are further explained later in the appendix.

  • You can use the Imports statement to symbolically handle library dependencies. Users of VisualStudio.NET can still use the Add Reference option in the Project menu from within the IDE; however, references may now be set inline with your code. Please consult Appendix E for an introduction to the VisualStudio.NET IDE.

I l @ ve RuBoard


Asp. Net. By Example
ASP.NET by Example
ISBN: 0789725622
EAN: 2147483647
Year: 2001
Pages: 154

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net