The following information is for the EMANT300

Namespace

Namespaces provide a hierarchical means of organizing the elements of one or more programs. An analogy would the naming of cities. Do you know that there are two cities named Austin in the world? One is in the USA and the other in Argentina. If you want to send mail to either city, you would write either Austin, USA or Austin, Argentina to be unambiguous. Country names like USA and Argentina in Visual Basic are called namespaces. In Visual Basic, the default namespace is the filename you gave. For your first program, the namespace is Hello

Class

Module Module1

A namespace is usually made up of one or more classes. A class is a definition for a specific kind of object. In subsequent exercises you will noticed that all the automatically generated codes have the same class called Module1. Thanks to the namespace difference, there is no confusion.

To make the transition from VB6 to VB .NET easier, the Module keyword is used instead of Class keyword. VB .NET converts the modules to classes automatically.

Fortunately for us, many classes are already predefined for the more common tasks that we need to do. In this program we make use of the Console class.

Console.WriteLine("Hello World")

The hello, world output is produced using the WriteLine method of the Console Class in the System namespace.

Console.WriteLine Method (String)

Writes the specified string value, followed by the current line terminator, to the standard output stream.

Main

Sub Main()

End Sub

The Main method is a member of the module Module1. The entry point of this application is the method named Main.

Important Notes

Please note the following while editing your Visual Basic code to avoid compilation errors

  • Visual Basic is not case-sensitive. If you type Console.Writeline as Console.writeline they are interpreted as the same. Visual Basic applies the appropriate case so if you typed writeline it is changed to Writeline when you hit enter.

  • The line continuation character _ allows you to split a statement over several lines

  • ' marks those lines for commenting and are ignored by the compiler

' This is a comment

End of Exercise 2

DAQ & Visual Basic Page 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37