O'Reilly logo

Programming Visual Basic .NET, Second Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Getting Started: “Hello World”

It is a time-honored tradition to start a programming book with a “Hello World” program. In this chapter, we will create, compile, and run a simple “Hello World” program written in Visual Basic .NET. The analysis of this brief program will introduce key features of the Visual Basic .NET language.

Example 2-1 illustrates the fundamental elements of a very simple Visual Basic .NET program.

Example 2-1. A simple “Hello World” program in VB.NET

   Module HelloWorld
   ' every console app starts with Main
      Sub Main( )
         System.Console.WriteLine("Hello World")
      End Sub
   End Module

That is the entire program. Compiling and running it displays the words “Hello World” at the console.

Examining Your First Program

The single greatest challenge when learning to program is that you must learn everything before you can learn anything. Even this simple program uses many features of the language that will be discussed in coming chapters, including statements, methods, objects, strings, inheritance, blocks, libraries, and polymorphism.

This chapter provides a whirlwind tour of a number of these concepts. I’ll then spend the rest of the book expanding on these areas and showing how they can be applied to create .NET applications.

Each program consists of a series of statements, which are instructions to the complier. In VB.NET, as in previous versions of Visual Basic, every statement ends with a carriage return/linefeed; you create one by pressing the Enter key. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required