HelloCLR.vb - Sample Application in VB

This section provides a tutorial example on compiling a sample program written in VB (Visual Basic) and executing it on the CLR (Common Language Runtime) of the .NET Framework.

New let's try to compile a simple application written in VB (Visual Basic) into a bytecode, so it can be executed by the CLR (Common Language Runtime) of the .NET Framework.

1. Enter the following source code in Notepad and save it file called, HelloCLR.vb:

' HelloCLR.vb
' Copyright (c) 2012 by Dr. Herong Yang, herongyang.com
Imports System
Public Module HelloCLR
   Sub Main()
     Console.WriteLine ("Hello VB CLR " _
        & Environment.Version.ToString() & "!")
   End Sub
End Module

2. Compile the source code stored in HelloCLR.vb using the .NET Framework 4 VB compiler in command window:

C:\herong>\windows\Microsoft.NET\Framework\v4.0.30319\vbc HelloCLR.vb
Microsoft (R) Visual Basic Compiler version 10.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

C:\herong>dir HelloCLR.*
     225 HelloCLR.cs
   6,656 HelloCLR.exe
     234 HelloCLR.vb

The output of the "vbc" command is the bytecode of the program in Intermediate Language stored in file, HelloCLR.exe, in the PE (Portable Executable) format.

3. When HelloCLR.exe is entered from a command line, Windows will invoke .NET CLR (Command Language Runtime) to perform the execution step:

Hello VB CLR 4.0.30319.239!

The CLR version number returned in the output shows that the program is executed in the .NET CLR virtual machine.

Last update: 2012.

Table of Contents

 About This Book

 1957 - FORTRAN Language Developed by IBM

 1970 - UNIX Operating System Developed by AT&T Bell Labs

 1971 - FTP Protocol Created by Abhay Bhushan

 1972 - C Language Developed by Dennis Ritchie

 1976 - vi Text Editor Developed by Bill Joy

 1977 - Apple II Designed by Steve Jobs and Steve Wozniak

 1977 - The Bourne Shell Developed by Stephen Bourne

 1978 - The C Shell Developed by Bill Joy

 1978 - Bash (Bourne-Again Shell) Developed by Brian Fox

 1979 - The Tcsh (TENEX C Shell) Developed by Ken Greer

 1983 - "Sendmail" Mail Transfer Agent Developed by Eric Allman

 1984 - Macintosh Developed by Apple Inc.

 1984 - X Window System Developed a MIT Team

 1991 - WWW (World Wide Web) Developed by Tim Berners-Lee

 1991 - Gopher Protocol Created by a University of Minnesota Team

 1995 - Java Language Developed by Sun Microsystems

 1995 - PHP: Hypertext Preprocessor Created by Rasmus Lerdorf

2002 - .NET Framework Developed by Microsoft

 Introduction of .NET Framework

 HelloCLR.cs - Sample Application in C#

HelloCLR.vb - Sample Application in VB


 PDF Printing Version