Practice Exercise 1
Welcome to Visual Basic

OBJECTIVES -- Upon completion of this lab you should be able to:

  •  Create, Run, Terminate, and Print a program

  •  Use objects such as form, label, and control button

  •  Become familiar with Visual Basic environment

 

DESCRIPTION -- In this lab you will create a simple program that shows and hides a label that reads "Welcome to Visual Basic!"

 

  

 

WALKTHROUGH      

  • Form:

Name, Text, BackColor properties, resizing, and centering.

  • Label:

Name, Text, BackColor, TextAlign, Font  and Visible properties.

  • CommandButton:

Name and Text properties.

  • Click event procedure

Setting label's visible property during run time

  • Save, Run, and Print a project or program

 

STEPS            

1.   Create a Windows Application project using the same steps that you saw in Running a Program.

 

2.   Click the form to bring up the form's properties.
Set the form's text property to: A Simple Program

Set the form's BackColor property to: pale yellow
Resize the form to be wider

 

3.   Add a label control to the form

 

4.   Set the label's text to: Welcome to Visual Basic!

Set the label's name to: lblWelcome 

Set the label's BackColor to: Transparent (In Web tab)

Set the label's Font property to: size 24

Set the label's TextAlign property to: MiddleCenter

Set the label's Visible property to: False

 

5.   Resize the label (and possibly the form) to have it resemble the display above.

 

6.   Add two command buttons to the form. 

 

7.   Set one command button's text property to: Show

And the command button's name to: cmdShow

Set the other command button's text property to: Hide

And the command button's name to: cmdHide

 

8.   In the cmdShow click event procedure in the code window add the following code:

lblWelcome.Visible = True

                              In the cmdHide click event procedure in the code window add the following code:

                        lblWelcome.Visible = False

 

9.   Save the form and project as: Welcome

 

10.  Run the program

 

11.  Print the program

 

DEMO

 

Sample Solution


            sln file