Simple example

The following is a very simple VB.NET program, a version of the classic "Hello world" example created as a console application:

Module Module1

    Sub Main()
        ' The classic "Hello World" demonstration program
        Console.WriteLine("Hello World!")
    End Sub

End Module

It prints "Hello world!" on a command-line window. Each line serves a specific purpose, as follows:

Module Module1

This is a module definition, a division of code similar to a class, although modules can contain classes. Modules serve as containers of code that can be referenced from other parts of a program.[3]
It is common practice for a module and the code file, which contains it, to have the same name; however, this is not required, as a single code file may contain more than one module and/or class definition.

Sub Main()

It defines a subroutine called "Main". "Main" is the entry point, where the program begins execution.[4]

Console.WriteLine("Hello world!")

This line performs the actual task of writing the output. Console is a system object, representing a command-line interface (also known as "console") and granting programmatic access to the operating system's standard streams. The program calls the Console method WriteLine, which causes the string passed to it to be displayed on the console.

Instead of Console.WriteLine, one could use MsgBox, which prints the message in a dialog box instead of a command-line window.[5]
Complex example

This piece of code is a solution to Floyd's Triangle:

Imports System.Console

Module Program

    Sub Main()
        Dim rows As Integer
         'Input validation.

        Do Until Integer.TryParse(ReadLine("Enter a value for how many rows to be displayed: "), rows) _
        AndAlso rows >= 1

            WriteLine("Allowed range is 1 and {0}", Integer.MaxValue)
       ' Output of Floyd's Triangle
        Dim current = 1

        For row = 1 To rows
            For column = 1 To row
                Write("{0,-2} ", current)
                current += 1

    End Sub

    ''' <summary>
    ''' Shadows Console.ReadLine with a version which takes a prompt string.
    ''' </summary>
    Function ReadLine(Optional prompt As String = Nothing) As String
        If prompt IsNot Nothing Then
        End If


       Return Console.ReadLine()
    End Function

End Module

Source: https://en.wikipedia.org/wiki/Visual_Basic_.NET