Computer Programming web Web programming Tips



Continue Programming in Visual Basic 6.0

By Sergey Skudaev



We continue learning how to create simple Visual Basic Application. Visit the previous page if you did not read it.

<<Part 1<<

Select Project from main menu and select Add Module. Hover mouse over a thumbnail to see a large image.

Visual basic tutorial: Add Module

Add module window displays. Select New Module and click OK

Visual basic tutorial: New Module

Select module from Project window and rename it to WinMain

Visual basic tutorial: Project View

Select Tools, Add Procedure

Visual basic tutorial: Project View

Type procedure name: main.

Visual basic tutorial: Project View



Select scope Public. Usually, it is already selected. Type inside Public Sub main procedure: "frmMain.Show"

Visual basic tutorial: frmMain.Show

Select Project, Project properties

Visual basic tutorial: frmMain.Show

On general tab type "Hello World"in project name field. In StartUp Object field select Sub Main

Visual basic tutorial: Project Properties: General

Double click Show Message command button on the form. Type the code:

lblMessage.Caption = "Hello World!"

Inside the Private Sub cmdShow_click() procedure. This code will be executed when user clicks Show Message Command button.

Visual basic tutorial: cmdShow_Click()

Your hello world application is ready to run. Select Run icon from main tool bar.

Visual basic tutorial: Show Message

Visual basic prompts you to save project.

Visual basic tutorial: Save Project

Save all project files in the start_vb folder

Visual basic tutorial: Name Files

When you saved project, Hello World form displays. Click Show Message button. Message displays

Visual basic tutorial: Hello World



Congratulation. You created your first Visual Basic application.
How it works?

Execution starts from sub main procedure. This procedure is defined in module as a public. It means the procedure has global scope. The code inside the sub main procedure is

frmMain.show.

frmMain is a name of the form.

Show is its method or function. When show method is executed the form displays.

When user clicks the Show Message button, button click event occurs. On button click event cmdShow_click procedure is executed. The code inside cmdShow_click procedure is

lblMessage.Caption = "Hello World!"

lblMessage is a label name. Caption is a label property. When code is executed, the string "Hello World" is assigned to label caption and is displayed on the label. The label background color, font and font color are label properties and can be set in the properties window or by code.

If you have any question or comments please register and post comments.

Password Keeper VB Application

Start Visual Basic: Part I

My eBooks on Amazon.com

US    UK    BR    CA
US    UK    BR    CA
US   UK   BR   CA