GUI Lab Manual
GUI Lab Manual
Program 1:Program to input two different integers using the function input box to compare
two numbers.
Source code:
Dim n1%, n2%
Private Sub cmdinput_Click( )
n1 = InputBox("Enter the first number", "first no")
Label1.Caption = "The First number is = " & n1
n2 = InputBox("Enter the Second number", "second no")
Label2.Caption = "The Second number is = " & n2
End Sub
Page No:
OUTPUT:-
Control Name
4 Commands
buttons
Cmd INPUT
Cmd COMPARE
Cmd CLEAR
Cmd EXIT
3 labels
Label 1
Label 2
Label3
1 Form
Form 1
Properties
Event
Name
Caption
Click
Caption
Caption
Program 2:Develop a class average program that will process an arbitrary number of
grades, each time the program is run.
Source code:
Option Explicit
Dim marks%, counter%, sum%
Dim aver As String
Page No:
Date:
OUTPUT:-
Control Name
Properties
Event
4 Commands
buttons
cmd READ
cmd AVERAGE
cmd CLEAR
cmd EXIT
Name
Caption
Click
1 Label
Label 1
Caption
1 Form
Form 1
Caption
Program 3:Program to find the maximum of three numbers using Sub procedure.
Source code:
Option Explicit
Dim a%, b%, c%
Private Sub cmdminimum_Click( )
a = (Text1.Text)
b = (Text2.Text)
c = (Text3.Text)
Call minimum(a, b, c)
End Sub
OUTPUT:-
4 Labels
1 Form
Control Name
Cmd SMALLEST
Cmd CLEAR
Cmd EXIT
Text 1
Text 2
Text 3
Label 1
Label 2
Label 3
Label 4
Form 1
Properties
Events
Name
Caption
Click
Text
Caption
Caption
Page No:
OUTPUT:-
Control Name
Cmd FACTORIAL
Cmd CLEAR
Cmd EXIT
Text 1
Label 1
Label 2
Form 1
Properties
Events
Name
Caption
Click
Text
Caption
Caption
Page No:
OUTPUT:-
Control Name
Properties
Cmd ENTER
Cmd CLEAR
Cmd EXIT
Command 1
Text 1
List 1
Form 1
Name
Caption
Index
Text
List
Caption
Events
Click
-
Page No:
OUTPUT:-
Control Name
Properties
Events
3 Command buttons
cmd DISPLAY
cmd CLEAR
cmd EXIT
Name
Caption
Click
2 Labels
Label 1
Label 2
Caption
1 Text box
Text 1
Text
1 List box
List
List
1 Check box
Check 1
Value
Page No:
OUTPUT:-
Control Name
Properties
Event
2 Commands
buttons
cmd EXIT
cmd CLEAR
Name
Caption
Click
1 Form
Form 1
Caption
Page No:
OUTPUT:-
Control Name
Property
Event
3 Commands
buttons
cmd PRINT
cmd CLEAR
cmd EXIT
Name
Caption
Click
1 Form
Form 1
Caption
Page No:
2 Text box
1 List box
1 Form
Control Name
Cmd EXIT
Cmd Clear
Label 1
Label 2
Label 3
Label 4(Result)
Text 1
Text 2
List 1
Form 1
Properties
Name
Caption
Events
Caption
Caption
List
Caption
Db/Click
-
Click
Program 10:Design an application to change the color, font size, type of the form using Scroll
Bar.
Source code:
Private Sub VScroll1_Change()
Text1.ForeColor = QBColor(VScroll1.Value)
End Sub
Page No:
OUTPUT:-
Control Name
Properties
Events
2 Commands
buttons
Cmd CLEAR
Cmd EXIT
Name
Caption
Click
1 Form
Form 1
Caption
2 Labels
Label 1
Label 2
Caption
2 Vscroll
Vscroll 1
Vscroll 2
Max,min
Max,min
Change
Page No:
OUTPUT:-
Control Name
Properties
Events
4 Commands
Cmd DATE
Cmd TIME
Cmd CLEAR
Cmd EXIT
Name
Caption
Click
1 Form
Form
Caption
Program 12:Program to demonstrate Adding and Subtracting dates with date and date
difference.
Source code:
Private Sub cmdaddsub_Click( )
Print "Date and Time :" & Now
Print "Date is :" & Date
Print "now+4 years :" & DateAdd("yyyy", 4, Now)
Print "now+130days : " & DateAdd("d", 130, Now)
Print "Days between 06/20/2013 and now :" & DateDiff("d", "06/20/2013", Now)
cmdaddsub.Enabled = False
End Sub
Page No:
OUTPUT:-
Control Name
Properties
Events
3 Commands
Name
Caption
Click
1 Form
Form
Caption
Page No:
OUTPUT:-
Control Name
Properties
Events
4 Commands
Cmd FILTER
Cmd SPLIT
Cmd CLEAR
Cmd EXIT
Name
Caption
Click
1 Form
Form
Caption
Dim x, y, r As Integer
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Page No:
OUTPUT:-
Properties Used:-
Control Used
Control Name
Properties
Events
1 Timer
Timer 1
Caption
Load
1 Form
Form
Caption
OUTPUT:-
Control Name
cmd ADDITEM
cmd REMOVEITEM
cmd CLEAR
cmd EXIT
Label 1
Text 1
Combo 1
Form 1
Properties
Events
Name
Caption
Click
Caption
Text
Text
Caption
Program 16:Design an application to validate the User Name and Password and display
appropriate message using msgbox ctrl.
Source code:
Dim username, password As String
Private Sub cmdin_Click ( )
username = Text1.Text
password = Text2.Text
If username = "COMPUTER" And password = "ASDF123" Then
MsgBox "WELCOME TO THE WORLD OF VISUAL BASIC "
Else
MsgBox "ACCESS DENIED"
End If
End Sub
Page No:
OUTPUT:-
Control Name
Properties
Events
3 Command
buttons
cmd LOG-IN
cmd CLEAR
cmd LOG-OUT
Name
Caption
Click
2 Labels
Label 1
Label 2
Caption
2 Text box
Text 1
Text 2
Text
Password char
2 Form
Form 1
Form 2
Caption
OUTPUT:-
Properties Used:-
2 Command
buttons
Control
Name
cmd CLEAR
cmd EXIT
1 Form
Form 1
Caption
Text
Alignment- 0 1 2
Font -BIU/D
Color-RGB
All should be visible
Menu Editor
Control Used
1 Text
Properties
Events
Name
Caption
Click
Procedure:
STEP 1: Start a new VB project and invoke the Menu Editor by select the Menu Editor option from the
Tools menu.
GO to tools Click on menu Editor a Menu Editor window will appear
OR
Right click on formSelect Menu Editor
STEP 2: For "Caption", type &ALIGNMENT For "Name", type mnuAlign.
STEP 3: Click the "right-arrow" button A ellipsis (...) will appear as the next item in the menu list,
indicating that this item is a level-two item (within "ALIGNMENT").
STEP 4: For "Caption", type LEFT; for "Name", type mnuLeft, and for "Shortcut", select Ctrl+L. By
specifying a shortcut.
STEP 5: For "Caption", type &CENTER; for "Name", type mnuCenter, and for "Shortcut", select
Ctrl+C.
STEP 6: Again For "Caption", type &RIGHT; for "Name", type mnuRight, and for "Shortcut", select
Ctrl+R.
STEP 7: Follow the same procedure for COLOR(GREEN, RED, BLUE) and for FONT (BOLD,
ITALIC, UNDERLINE , - and DEFAULT).
STEP 8: At this point, we are done creating our menu entries, so click the OK button. That will dismiss
the menu editor and return focus to the VB IDE.
STEP 9: Back in the VB IDE, your form will now have a menu, based on what we have set up in the
Menu Editor. If we click on a top-level menu item
STEP 10: Double-click the form to open the Code Editor, and write the program code.
OUTPUT:-
Control
Name
Properties
Events
1 Label
Label1
Name
Caption (Visual Basics)
1 Form
Form 1
Caption
Text
Font BOLD
Font ITALIC
FONT UNDERLINE
All should be visible
(Except POP)
Menu Editor
1 Text
Procedure:
STEP 1: Start a new VB project and place a label on the form. Name the label lblTestText. Set the
Caption to VISUAL BASICS
STEP 2: Open the Menu Editor, and create a top-level item with a Caption value of POP and the Name
mnuPop. Also importantly uncheck the Visible checkbox. In order for a menu to be a pop-up menu, it
must be invisible.
STEP 3: Create the following level-two menu items below the POP top-level menu. (When creating
these level-two items, keep the Visible box checked.)
STEP 4:
STEP 5: Click OK to save your changes. Note: When you return to the IDE, we will NOT see this
menu on the form (remember it's a pop-up menu, and it will only be visible when invoked through
code).
STEP 6: Double-click the form to open the Code Editor, and write the program code.
STEP 7: Button parameter is testedfor vbRightButton as is conventional, we only want to pop up the
menu if the user right-clicks on the label. If the user clicks the right mouse button, the PopupMenu
statement is executed.
Output:
Control Name
Properties
Events
3 Commands
buttons
Cmd DIVIDE
Cmd CLEAR
Cmd EXIT
Name
Caption
Click
3 Label
Label 1
Label 2
Label 3
Caption
2 Text box
Text 1
Text 2
Text
1 Form
Form 1
Caption
Page No:
Output:
Control Name
cmd READ
cmd SEARCH
cmd CLEAR
cmd EXIT
Label 1
Label 2
Properties
Events
Name
Caption
Click
Caption
1 Text box
Text 1
Text
1 List box
List
List
1 Form
Form 1
Caption
Program 20:Design an application which performs the following operations on the data base
the form using ADO 1.ADD 2.UPDATE 3.DELETE
Source code:
Private Sub cmdadd_Click()
Data1.Recordset.AddNew
cmdadd.Visible = False
cmdupdate.Visible = True
End Sub
Output:
Control Name
Property
Events
3 Commands
buttons
Cmd UPDATE
Cmd DELETE
Cmd ADD
Name
Caption
Click
2 Text box
Text 1
Text 2
Text
Data Source
Data Field
2 Labels
Label 1
Label 2
Caption
1 ADODC
DATA 1
Caption
Page No:
PROCEDURE:
Step 1: Right click on the toolbar
(OLEDB)
apply
components
ok.
Step 4: Then a dialog box will appear, right click on the properties
will appear give table name
close
add field
new
ok
double click on the table name, then a dialog box will appear,
then click on ADD (To add details click on update. If you want to enter some more details then repeat
step 4. )
click on next
select the Microsoft access file which you have saved and open it
click on
click
on ok.
Step 6: Go to Record source
stored procedure name
apply
Step 7: Draw 4 command buttons for add, update, delete, and exit.
Step 8: Draw 2 labels for student name and roll no.
Step 9: Take 2 text boxes
Step 10: Then write the code.
click on table or