Hello World

This is the famous universally recognised first stage of a tutorial used in every programming language from Java to C++. This tutorial will show you in Visual Basic 5 (same as 6) but this does not matter as this example can be done in any version of Visual Basic.

Printer Friendly Download Tutorial (42.4KB) Download Source Code (7KB)

Step 1

Load Microsoft Visual Basic, then select Standard EXE Project if VB5/6, click on the option then click Open, see below:

New Project

Step 2

A Blank Form named Form1 should then appear, see below:

Form 1

Step 3

Then from the Visual Basic Components Menu Select the Command Button Control:

Command Button

Step 4

Draw a Command Button on the Form, see below:

Form1 with Button

Step 5

Then goto the Properties box and change the Caption property from Command1 to Click Here, see below:

Properties

Step 6

Double Click on the Command Button and type in the Command1_Click() Sub:

MsgBox "Hello World",vbInformation,"Test"

See Below:

Click Event

Step 7

Save the Project (for example prjHelloWorld) into a vacant folder as you have finished the application. Click on Start / Run Start / Run or Press F5 and the below will appear:

Application Running

Step 8

Now Click where it Says Click Here and a Message Box will appear, which will look something like this:

Hello World

Step 9

Just Click Ok and End / Stop End / Stop the application.

That was your first working Visual Basic Application! Try changing the Text or the Title, which is the last part after the vbInformation remark, or have a go at changing the code and extending it, you can learn a lot from this simple application!

Copyright Comentsys © 1997 - 2009, All rights reserved. About | Contact | Link to Page
Valid XHTML 1.1! Valid CSS Level Double-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0 This website is ICRA rated