Step 2. Hello, World!We're sorry but we just couldn't resist the
temptation... We just have to do the classic "Hello, World!" application
that was first written in the C language.
Source Code Modifications
- Double-click the file 'module1.vb' in the Solution Explorer. You can
display the Solution Explorer using the View menu.
- Make the changes highlighted in red to
the pre-generated template (module1.vb).
' Import namespaces Imports
System
Module Module1
Sub
Main()
Console.WriteLine ("Hello, VB.NET World!")
End Sub
End Module
- Notice that as you type, Visual Studio will help you with the names
of classes and functions, since the .NET Framework publishes the type
information.
Compiling Your Application
- Now that you have made your modifications, you can compile the
Visual Basic project by simplying selecting Build in the Build menu.
- Errors and messages from the VB compiler will be displayed in the
Output window. If there were no errors, you can run the Hello World
application by clicking Start without
Debugging under the Debug menu.
Program OutputThis is a screenshot of the output from the Hello
World sample application when run from within the Visual Studio
environment.
Understanding the ChangesThe WriteLine() function of the System.Console class prints the string passed to it
followed by a single new line character. The function can take a number of
other data types including integers and floating-point numbers.
Control passes to the Main() function after
the program has been loaded. That is why we insert the call to WriteLine() in the procedure.
back
to top |