Continue Programming in Visual Basic 6.0

VB Lesson 1 (Continue)

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

Please rate the tutorial

1 2 3 4 5 6 7 8 9 10



Learn SQL Programming By Examples [Kindle Edition]2.99

Learn PHP Programming by Examples [Kindle Edition] $2.99

Learn Visual Basic 6.0 [Kindle Edition] $1.99

How to Build Your Own Web Site from Scratch [Kindle Edition] $1.49

New-trip.com website source code

Comments
 
Register to add comments ( 1000 char ) for start_vb_cont.php.

 


You can find a lot of resources on Internet to start learning VB. Visit link http://www.appdev.com/visual_basic_training.asp

Start Visual Basic: Part I