1 Shah Abdul Latif University Khairpur (mir s), Sindh Department of Computer Science

INTRODUCTION TO VISUAL PROGRAMMING
Lab # 1
Objective: The objective is to review the basics of Visual programming. Theory Visual Basic (Business All-purpose Symbolic Instruction Code) is a tool that allows you to develop Windows (Graphic User Interface - GUI) applications.

How to open Visual Basic 6.0 Step 1: First click on start menu. Step 2: Click on All programs. Step 3: Microsoft Visual Basic 6.0 after that click on visual basic 6.0.

Visual Basic

2 Shah Abdul Latif University Khairpur (mir s), Sindh Department of Computer Science Visual Basic will open

New Project

Visual Basic

3 Shah Abdul Latif University Khairpur (mir s), Sindh Department of Computer Science

You must select/open Standard.Exe according to the above figure

Now, you can design a program by adding some tools like button, comobox, textbox, label etc. Program: 1 Write a program that display the message box of your name. Solution: Running a simple VB Program in Visual Basic 6.0 Step 1. First of all you have to select a form1. Step 2. Now, select a button from toolbox and draw on the form1 that button. Step 3. Now change the caption of form1 and button1, Form1 = MessageBox

Visual Basic

Step 5. Sindh Department of Computer Science Button1 = MessageBox Step 4. you can run this program. Step 6: During executation Visual Basic . After the code writing. Now.4 Shah Abdul Latif University Khairpur (mir s). double click on button for code. For running program you must click on start button.

5 Shah Abdul Latif University Khairpur (mir s). Visual Basic . Step 3: Add three labels First for (Enter first value). Step 4: Place a button also change the name property into Calculate. Solution Step 1: Select Form1. Program 2: Write a program that add to numbers and display the answer. second(Enter second value) and third (Answer). Step2: Add two textboxes (text box1 and text box2). Sindh Department of Computer Science Step 7: To stop the program now you click on End button.

Program 3: Write a program in which we input a number and that display it square. Sindh Department of Computer Science Step 5: Now double click on button calculate to write code. Step 2: Add a label for Enter number for finding the square.6 Shah Abdul Latif University Khairpur (mir s). Solution Step 1: Select form1. Visual Basic . Step 4: Add two buttons by name of Exit and Calculate. Step 3: Add a text box in which you write any number.

Step 3: Add two text boxes in which you write any number and other text box for display answer. Solution: Step 1: Select form1. Sindh Department of Computer Science Step 5: Now double click on the calculate button for code and exit button. Program 4: Write code for cube according to the program 3. Step 2: Add a label for Enter number for finding the cube of give number. Step 4: Add two buttons by name of Clear (both text boxes clear) and Calculate. Visual Basic .7 Shah Abdul Latif University Khairpur (mir s).

Sindh Department of Computer Science Step 5: Now double click on the calculate button for code and clear button. Visual Basic . Solution: Step 1: Select form1. Program 5: Write a program in which you enter your marks and that display the Percentage and grade.8 Shah Abdul Latif University Khairpur (mir s). Step 3: Add two text boxes in which you write your marks and total marks. Step 2: Add two labels for Enter your marks and Enter total marks for finding the Percentage. Step 4: Add a buttons by name Check.

Lab # 2 Objective: The object is to understand the concept the if-statement. Sindh Department of Computer Science Step 5: Now double click on the check button for finding percentage. Program 6: Write a program which compares two numbers. Solution: Step 1: Select form1. which number is greater/ less. Theory THE if STATEMENT: To make a decision in simplest way in Visual Basic program is to use the If Then statement. Step 2: Add two labels for Enter first number and Enter second number for comparing numbers.9 Shah Abdul Latif University Khairpur (mir s). Visual Basic .

Step 4: Add a buttons by name compare. Visual Basic .10 Shah Abdul Latif University Khairpur (mir s). Step 3: Add two text boxes in which you write name and Password. Solution Step 1: Select form1 and form2 Step 2: Add two labels for User name and Password in form1. Sindh Department of Computer Science Step 3: Add two text boxes in which you write numbers. Step 5: Now double click on the compare button for the code. Program 7: Write a program that get user name and password and show the next form.

Now double click on the Sign in button of form1 for code.11 Shah Abdul Latif University Khairpur (mir s). Step 6: Add a button Log out that exit the program. Sindh Department of Computer Science Step 4: Add a buttons by name Sing in. Form2 Step 5: Add a picture box then select a picture. Step 7. Visual Basic .

Step 4: Add a buttons by name Check. Step 3: Add a text box for input the marks. Step 2: Add a labels for Enter your marks for Grade.12 Shah Abdul Latif University Khairpur (mir s). Solution: Step 1: Select form1. Theory SELECT CASE STATEMENT: It is more flexible and a clearer format. Sindh Department of Computer Science Lab # 3 Objective: The object is to understand the concept of Select case statement. Visual Basic . Program 8: Write a program that get marks from user and give output in Grade/Pass and fail.

Theory Loop: It is a program that repeat certain number times the statement. Lab # 4 Objective: The object is to understand the concept of Loops. For Loop: The for loop execute the section of program a fixed number of times.13 Shah Abdul Latif University Khairpur (mir s). Sindh Department of Computer Science Step 5: Now double click on the check button for the code. Solution Visual Basic . Program 9: By using loop create a program that displays number from 1 to 10.

Step 2: Add two labels for Enter base and Power for finding power of a number. Program 10: By using For loop create a program that get base number and power from user and displays the power of a number. Solution: Step 1: Select form1.14 Shah Abdul Latif University Khairpur (mir s). Visual Basic . Sindh Department of Computer Science Step 1: Select form1. Step 3: Add two text boxes for input of numbers. Step 2: Add a buttons by name Click Here Step 3: Now double click on the button click here.

15 Shah Abdul Latif University Khairpur (mir s). Step 5: Now write the code. Solution Step 1: Select form1. Visual Basic . Program 11: By using while loop create a program that get a number from user and displays the power of a number. Step 4: Add a buttons for finding square. Sindh Department of Computer Science Step 4: Add two buttons one for clear text boxes and next for calculate the power. Step 3: Add text boxes for input of number. Step 2: Add a label for Enter number.

Visual Basic . Step 4: Add two buttons Odd and Even. Sindh Department of Computer Science Step 5: Now write the code. Solution Step 1: Select form1. Program 12: Create a program that displays odd and even numbers.16 Shah Abdul Latif University Khairpur (mir s). to print these numbers on form.

Visual Basic . Step 4: Add a list box for displaying the result of table. Program 13: Create a table by using loop. Sindh Department of Computer Science Step 3: Write the code for odd and even number using for loop.17 Shah Abdul Latif University Khairpur (mir s). Step 3: Add text boxes for input of number. Step 5: Add a buttons click here. Solution Step 1: Select form1. Step 2: Add a label for Enter number for which you want to display the table.

Visual Basic . Step 2: Add a buttons for display hello 10 times by using while loop.18 Shah Abdul Latif University Khairpur (mir s). Program 14: Create a program to display 10 time hello world! Message by using do-while loop. Solution Step 1: Select form1. Sindh Department of Computer Science Step 6: Now write the code for the table.

19 Shah Abdul Latif University Khairpur (mir s). Step 3: Add two check boxes first for font bold and other for font italic. Step 2: Add a text box for input some text. Sindh Department of Computer Science Step 3: Now write the code. Visual Basic . Program 15: Write a program for bold text and Italic font using check boxes. Solution Step 1: Select form1.

Step 2: Add five labels for (day. date. Solution Step 1: Select form1. Visual Basic . date. Program 16: Write a program that display time. time. Sindh Department of Computer Science Step 4: Now write the code of that program. year and day. month and year). month.20 Shah Abdul Latif University Khairpur (mir s).

year. Sindh Department of Computer Science Step 3: Write the code of the program. month. hour. date. minutes and seconds). Step 2: Add five labels for display (month. Program 17: By using check boxes write a program that display time. minutes and seconds).21 Shah Abdul Latif University Khairpur (mir s). hour. Step 4: Add a button OK. Solution Step 1: Select form1. Step 3: Add five check boxes (month. year and day. Visual Basic . year.

Sindh Department of Computer Science Step 5: Write the following code for the program. Visual Basic . Write a program that get input (in input box) from user and give answer.22 Shah Abdul Latif University Khairpur (mir s). Program 18.

remove. Visual Basic . italic and underline). write a program that get input (name). and perform add.23 Shah Abdul Latif University Khairpur (mir s). clear and font (Bold. By using list box. Sindh Department of Computer Science Code Program 19.

24 Shah Abdul Latif University Khairpur (mir s). Sindh Department of Computer Science Code Visual Basic .

Yes No. try again etc). like (OK only. Information. Error. Sindh Department of Computer Science Program 20: Create a program that show all types dialog boxes. Ok cancel. Exclamation. Code Visual Basic .25 Shah Abdul Latif University Khairpur (mir s).

26 Shah Abdul Latif University Khairpur (mir s). Sindh Department of Computer Science Program 21: By using Array write a program that gets input box user and display these number with their position. Code Visual Basic .

Step 3: Add a button which concatenate both text boxes text. Step 5: Now write the code for the program. Step 4: Add two labels for display the concatenated result of text. Step 2: Add two text boxes for input some text.27 Shah Abdul Latif University Khairpur (mir s). Write a program that gets strings from user and concatenate the strings. Visual Basic . Sindh Department of Computer Science Strings Program 22. Solution Step 1: Select form1.

28 Shah Abdul Latif University Khairpur (mir s). Step 3: Write the code for the program. Visual Basic . Solution Step 1: Select form1. Write a program in you use like keyword which show the difference like True/False. Step 2: Add a button for Like Demo. Sindh Department of Computer Science Program 23.

29 Shah Abdul Latif University Khairpur (mir s). Write a program that in that works like a windows explorer. also show file s location. Sindh Department of Computer Science Program 24. Solution Code Visual Basic . folders. by using drives. files and pictures.

Sindh Department of Computer Science Graphics Program 25.30 Shah Abdul Latif University Khairpur (mir s). Write a program that show a pixel point on the form. Code Visual Basic .

circle and rectangle). Sindh Department of Computer Science Program 26. that gets input using two text boxes first(get border style from 0 to 6) and second (get border width). Code Program 27: Write a program that display graphics shapes (line. Visual Basic . Write a program that print line.31 Shah Abdul Latif University Khairpur (mir s).

Solution Visual Basic .32 Shah Abdul Latif University Khairpur (mir s). Sindh Department of Computer Science Code Program 28: Write a program that tells us the Location of button.

Solution Visual Basic .33 Shah Abdul Latif University Khairpur (mir s). Sindh Department of Computer Science Code Program 29: Write a program that displays the size (Height and width) of form.

Step 2: Add a picture box. Step 5: Add a check box for Auto Draw picture. Visual Basic . Sindh Department of Computer Science Code Program 30: write a program that draw a graphical picture of circle with different styles. Step 3: Add three text boxes for input of number.34 Shah Abdul Latif University Khairpur (mir s). Step 4: Add two buttons for (Draw picture and remove the picture). Solution Step 1: Select form1.

Visual Basic . Sindh Department of Computer Science Step 6: Now write the code for the program.35 Shah Abdul Latif University Khairpur (mir s).

Sindh Department of Computer Science Visual Basic .36 Shah Abdul Latif University Khairpur (mir s).

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.