GUI Lab Manual
GUI Lab Manual
for
Third Semester
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
Program 1:-
Program to input two different integers using the function input box to compare
two numbers.
Source code:
Dim n1%, n2%
OUTPUT:-
Properties Used:-
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
OUTPUT:-
Properties Used:-
Program 3:-
Program to find the maximum of three numbers using Sub procedure.
Source code:
Option Explicit
Dim a%, b%, c%
OUTPUT:-
Properties Used:-
Program 4:-
Program to demonstrate function procedure.
Source code:
Option Explicit
Dim num As Integer
Dim i%
OUTPUT:-
Properties Used:-
Program 5:-
Program to demonstrate control array.
Source code:
Dim accesscode
OUTPUT:-
Properties Used:-
Program 6:-
Program to demonstrate dynamic array.
Source code:
Option Explicit
Option Base 1
Dim a() As Integer
Dim n%, i%
OUTPUT:-
Properties Used:-
cmd DISPLAY
Name
3 Command buttons cmd CLEAR Click
Caption
cmd EXIT
Label 1
2 Labels Caption -
Label 2
1 Text box Text 1 Text -
1 List box List List -
1 Check box Check 1 Value -
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
Program 7:-
Program to demonstrate Param Array.
Source code:
Option Explicit
OUTPUT:-
Properties Used:-
Program 8:-
Program to demonstrate Function Array.
Source code:
Option Base 1
OUTPUT:-
Properties Used:-
cmd PRINT
3 Commands Name
cmd CLEAR Click
buttons Caption
cmd EXIT
Program 9:-
Program to demonstrate String Functions.
Source code:
Private Sub List1_DblClick( )
If (List1.List(List1.ListIndex) = "STRCOMP") Then
n = StrComp(Text1.Text, Text2.Text)
If (n = 0) Then
Label4.Caption = "Strings are identical"
ElseIf (n = -1) Then
Label4.Caption = Text1.Text & " is less than " & Text2.Text
Else
Label4.Caption = Text1.Text & " is greater than " & Text2.Text
End If
ElseIf (List1.List(List1.ListIndex) = "STRREV") Then
Text2.Text = StrReverse(Text1.Text)
ElseIf (List1.List(List1.ListIndex) = "UCASE") Then
Text2.Text = UCase(Text1.Text)
ElseIf (List1.List(List1.ListIndex) = "LCASE") Then
Text2.Text = LCase(Text1.Text)
ElseIf (List1.List(List1.ListIndex) = "INSTR") Then
i = InStr(1, Text1.Text, Text2.Text)
If i = 0 Then
Label4.Caption = " Second String Not Found "
Else
Label4.Caption = " Second String Found At Position " & i
End If
End If
End Sub
OUTPUT:-
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
Properties Used:-
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
OUTPUT:-
Properties Used:-
Vscroll 1 Max,min
2 Vscroll Change
Vscroll 2 Max,min
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
Program 11:-
Program to demonstrate Date and Time function.
Source code:
Private Sub cmddate_Click( )
Print "DATE FUNCTION "
Print "Current Date and Time : " & Now
Print "Date :" & Date
Print "Day :"; Day(Date)
Print "Weekday : "; Weekday(Date)
Print "Weekday Name : "; WeekdayName(Weekday(Date))
Print "Month : " & Month(Date)
Print "Month Name : "; MonthName(Month(Date))
Print "Month Name : abbreviated " & MonthName(Month(Date), True)
Print "...................................................................."
cmddate.Enabled = False
End Sub
OUTPUT:-
Properties Used:-
Cmd DATE
Cmd TIME Name
4 Commands Click
Cmd CLEAR Caption
Cmd EXIT
1 Form Form Caption -
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
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
OUTPUT:-
Properties Used:-
Program 13:-
Program to demonstrate Function Filter and Split.
Source code:
Private Sub cmdFILTER_Click( )
Dim a(6) As String, b() As String
a(0) = "JAVA"
a(1) = "VB6"
a(2) = "C++"
a(3) = "VB6"
a(4) = "C"
a(5) = "VB6"
Print "FILTER FUNCTION"
Print "Filtering for the string" & Space$(2) & "VB6"
b = Filter(a, "VB6")
Call display_array(b)
Print "--------------------------------------------------------"
Erase b
Print "Filtering for string after the " & Space$(2) & "VB6"
b = Filter(a, "VB6", False)
Call display_array(b)
Print "--------------------------------------------------------"
cmdFILTER.Enabled = False
End Sub
OUTPUT:-
Properties Used:-
Cmd FILTER
Cmd SPLIT Name
4 Commands Click
Cmd CLEAR Caption
Cmd EXIT
Program 14:-
Program to demonstrate timer control.
Source code:
Option Explicit
Dim x, y, r As Integer
End Sub
OUTPUT:-
Properties Used:-
Program 15:-
Program to demonstrate Combobox Control.
Source code:
Dim str As String
OUTPUT:-
Properties Used:-
Control Used Control Name Properties Events
cmd ADDITEM
4 Command cmd REMOVEITEM Name
Click
buttons cmd CLEAR Caption
cmd EXIT
1 Labels Label 1 Caption -
1 Text box Text 1 Text -
1 Combo box Combo 1 Text -
1 Form Form 1 Caption -
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
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
OUTPUT:-
Properties Used:-
cmd LOG-IN
3 Command Name
cmd CLEAR Click
buttons Caption
cmd LOG-OUT
Label 1
2 Labels Caption -
Label 2
Text 1 Text
2 Text box *
Text 2 Password char
Form 1
2 Form Caption -
Form 2
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
Program 17 a:-
Program to demonstrate Pull-Down menu.
Source code:
Private Sub mnured_Click( )
Text1.ForeColor = vbRed
End Sub
OUTPUT:-
Properties Used:-
Control
Control Used Properties Events
Name
2 Command cmd CLEAR Name
Click
buttons cmd EXIT Caption
1 Form Form 1 Caption -
Alignment- 0 1 2
Font -BIU/D
1 Text Text Menu Editor
Color-RGB
All should be visible
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
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 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.
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
Program 17 b:-
Program to demonstrate POP-UP menu.
Source code:
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
OUTPUT:-
Properties Used:-
Control
Control Used Properties Events
Name
Name
1 Label Label1 -
Caption (Visual Basics)
1 Form Form 1 Caption -
Font BOLD
Font ITALIC
1 Text Text FONT UNDERLINE Menu Editor
All should be visible
(Except POP)
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
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.
Department of Computer Science & Engineering
Government Polytechnic Karwar
III sem GUI Lab
Page No: Date:
Program 18:-
Program to demonstrate Nested on Error Statement.
Source code:
Private Sub cmddivide_Click ( )
Dim n%, d%
On Error GoTo input_handle
n = Text1.Text
d = Text2.Text
On Error GoTo divide_by_zero_handle
Label3.Caption = "Result is=" & n / d
Exit Sub
divide_by_zero_handle:
Label3.Caption = "Attempted Divide By zero"
Exit Sub
input_handle:
Label3.Caption = "Attempted Non-Numeric Output"
Exit Sub
End Sub
Output:
Properties Used:-
Program 19:-
Program to demonstrate Linear Search.
Source code:
Dim a(10) As Integer
Dim key%, n%, i%
Output:
Properties Used:-
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:
Properties Used:-
Cmd UPDATE
3 Commands Name
Cmd DELETE Click
buttons Caption
Cmd ADD
Text
Text 1
2 Text box Data Source -
Text 2
Data Field
Label 1
2 Labels Caption -
Label 2
PROCEDURE:
Step 1: Right click on the toolbar components select the Microsoft ADO data control 6.0
(OLEDB) apply ok.
Step 3: Go to ADDINS visual data manager. A dialog box will appear. Go to file new
Microsoft access version 7.0 MDB create a file and save.
Step 4: Then a dialog box will appear, right click on the properties new table, another dialog box
will appear give table name add field a dialog box will appear (give Roll No, Name etc) ok
close click on build table 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. ) close the window.
Step 5: Right click on ADODC button ADODC properties , a dialog box will appear click on
build select Microsoft jet 4.0 OLE DB provider click on next enter the database name
select the Microsoft access file which you have saved and open it click on test connection click
on ok.
Step 6: Go to Record source click on command type select 2-nd cmd table click on table or
stored procedure name then select the file apply ok.
Step 7: Draw 4 command buttons for add, update, delete, and exit.
Step 9: Take 2 text boxes go to properties and change data source and data field.