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.
Visual Basic will open
New Project
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,
Button1 = MessageBox
Step 4. Now, double click on button for code.
Step 5. After the code writing, you can run this program. For running program you must click on start button,
Step 7: To stop the program now you click on End button,
Program 2: Write a program that add to numbers and display the answer. Solution
Step 1: Select Form1.
Step2: Add two textboxes (text box1 and text box2).
Step 3: Add three labels First for (Enter first value), second(Enter second value) and third (Answer). Step 4: Place a button also change the name property into Calculate.
Step 5: Now double click on button calculate to write code,
Program 3: Write a program in which we input a number and that display it square. Solution
Step 1: Select form1.
Step 2: Add a label for Enter number for finding the square. Step 3: Add a text box in which you write any number. Step 4: Add two buttons by name of Exit and Calculate.
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. Solution:
Step 1: Select form1.
Step 2: Add a label for Enter number for finding the cube of give number.
Step 3: Add two text boxes in which you write any number and other text box for display answer. Step 4: Add two buttons by name of Clear (both text boxes clear) and Calculate.
Step 5: Now double click on the calculate button for code and clear button.
Program 5: Write a program in which you enter your marks and that display the Percentage and grade. Solution:
Step 1: Select form1.
Step 2: Add two labels for Enter your marks and Enter total marks for finding the Percentage. Step 3: Add two text boxes in which you write your marks and total marks.
Step 5: Now double click on the check button for finding percentage.
Lab # 2
Objective: The object is to understand the concept the if-statement.
TheoryTHE if STATEMENT: To make a decision in simplest way in Visual Basic program is to use the If…Then statement.
Program 6: Write a program which compares two numbers, which number is greater/ less. Solution:
Step 1: Select form1.
Step 3: Add two text boxes in which you write numbers. Step 4: Add a buttons by name compare.
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. Solution
Step 1: Select form1 and form2
Step 2: Add two labels for User name and Password in form1. Step 3: Add two text boxes in which you write name and Password.
Step 4: Add a buttons by name Sing in.
Form2
Step 5: Add a picture box then select a picture. Step 6: Add a button Log out that exit the program.
Lab # 3
Objective: The object is to understand the concept of Select case statement.
TheorySELECT CASE STATEMENT:
It is more flexible and a clearer format.
Program 8: Write a program that get marks from user and give output in Grade/Pass and fail. Solution:
Step 1: Select form1.
Step 2: Add a labels for Enter your marks for Grade. Step 3: Add a text box for input the marks.
Step 5: Now double click on the check button for the code.
Lab # 4
Objective: The object is to understand the concept of Loops.
TheoryLoop: It is a program that repeat certain number times the statement.
For Loop: The for loop execute the section of program a fixed number of times. Program 9: By using loop create a program that displays number from 1 to 10. Solution
Step 1: Select form1.
Step 2: Add a buttons by name Click Here
Step 3: Now double click on the button click here.
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.
Step 2: Add two labels for Enter base and Power for finding power of a number. Step 3: Add two text boxes for input of numbers.
Step 4: Add two buttons one for clear text boxes and next for calculate the power.
Step 5: Now write the code,
Program 11: By using while loop create a program that get a number from user and displays the power of a number.
Solution
Step 1: Select form1.
Step 2: Add a label for Enter number. Step 3: Add text boxes for input of number. Step 4: Add a buttons for finding square.
Step 5: Now write the code,
Program 12: Create a program that displays odd and even numbers. Solution
Step 1: Select form1.
Step 3: Write the code for odd and even number using for loop,
Program 13: Create a table by using loop. Solution
Step 1: Select form1.
Step 2: Add a label for Enter number for which you want to display the table. Step 3: Add text boxes for input of number.
Step 4: Add a list box for displaying the result of table. Step 5: Add a buttons click here.
Step 6: Now write the code for the table,
Program 14: Create a program to display 10 time hello world! Message by using do-while loop. Solution
Step 1: Select form1.
Step 3: Now write the code,
Program 15: Write a program for bold text and Italic font using check boxes. Solution
Step 1: Select form1.
Step 2: Add a text box for input some text.
Step 4: Now write the code of that program,
Program 16: Write a program that display time, date, month, year and day. Solution
Step 1: Select form1.
Step 3: Write the code of the program,
Program 17: By using check boxes write a program that display time, date, month, year and day. Solution
Step 1: Select form1.
Step 2: Add five labels for display (month, year, hour, minutes and seconds). Step 3: Add five check boxes (month, year, hour, minutes and seconds). Step 4: Add a button OK.
Step 5: Write the following code for the program,
Code
Program 19. By using list box, write a program that get input (name), and perform add, remove, clear and font (Bold, italic and underline).
Program 20: Create a program that show all types dialog boxes, like (OK only, Ok cancel, Yes No, Error, Exclamation, Information, try again etc).
Program 21: By using Array write a program that gets input box user and display these number with their position.
Strings
Program 22. Write a program that gets strings from user and concatenate the strings. Solution
Step 1: Select form1.
Step 2: Add two text boxes for input some text.
Step 3: Add a button which concatenate both text boxes text. Step 4: Add two labels for display the concatenated result of text.
Program 23. Write a program in you use like keyword which show the difference like True/False. Solution
Step 1: Select form1.
Step 2: Add a button for Like Demo.
Program 24. Write a program that in that works like a windows explorer, by using drives, folders, files and pictures, also show file’s location.
Solution
Graphics
Program 25. Write a program that show a pixel point on the form.
Code
Program 26. Write a program that print line, that gets input using two text boxes first(get border style from 0 to 6) and second (get border width).
Code
Code
Program 28: Write a program that tells us the Location of button. Solution
Code
Program 29: Write a program that displays the size (Height and width) of form. Solution
Code
Program 30: write a program that draw a graphical picture of circle with different styles. Solution
Step 1: Select form1. Step 2: Add a picture box.
Step 3: Add three text boxes for input of number.
Step 4: Add two buttons for (Draw picture and remove the picture). Step 5: Add a check box for Auto Draw picture.