"Hello, World" Visual Basic

.

The following console program is the Visual Basic version of the traditional "Hello, World!" program, which displays the string "Hello, World!".

' A "Hello, World!" program in Visual Basic.
Module Hello
  Sub Main()
      MsgBox("Hello, World!") ' Display message on computer screen.
  End Sub
End Module
The important points of this program are the following:
  • Comments
  • The Main procedure
  • Input and output
  • Compilation and execution


 The main Procedure

Every Visual Basic application must contain a procedure called Main. This procedure serves as the starting point and overall control for your application. It is called when your module is loaded.
There are four varieties of Main:
  • Sub Main()
  • Sub Main(ByVal cmdArgs() As String)
  • Function Main() As Integer
  • Function Main(ByVal cmdArgs() As String) As Integer
The most common variety of this procedure is Sub Main(). Unless you are creating a Windows Forms application, you must write the Main procedure for applications that run on their own.

To compile and run the program from the IDE

  1. Create a Visual Basic console application project.
  2. Copy the code into the project.
  3. Choose the appropriate Build command from the Build menu, or press F5 to build and run (corresponding to Start in the Debug menu).

     
    Related Posts Plugin for WordPress, Blogger...