Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 77

Submitted To: Submitted by:

Ms. Saroj Sharma Name:

(Assist. Prof. in CS.Dept) Class: M.sc. 3rd sem

Roll no:
INDEX
Sr.No Programs Signature
1. Write a program for login form.
2. Write a program using cut,copy,paste textboxes.
3. Write a program for tour travel agency.
4. Write a program using checkboxes.
5. Write a program using listbox.
6. Write a program using timer control.
7. Write a program using shape control and scroll
control.
8. Write a program using picture control.
9. Write a program using imagebox control.
10. Write a program using directory,drive,filebox.
11. Write a program using scroll bar control.
12. Write a program to change the color of textbox
13. Write a program find out maximum of three
number.
14. Write a program call by value and call by
reference.
15. Write a program to find out even and odd number.
16. Write a program to factorial no using function.
17. Write a program to display matrices using array.
18. Write a program to create a menubar and display
message using messagebox.
19. Write a program to creating a popup menu.
20. Write a program to print fibanoic series.
21. Write a program to show different textbox using
select case statement.
22. Write a program to print the sum of series using do
while loop.
23. Write a program to show pyramid.
24. Write a program to design a calculator using
control array.
25. Write a program using listbox(Indian
team,Australia team).
26. Write a program to design a restaurant application.
27. Steps of ODBC.
28. Steps of ADODC.
29. Write a program to make an application using
ADODC control.
30. Write a program to create a active x control.
1.Write a program for login form.

CODING

Private Sub Command1_Click()


If Text2.Text = "kajalgoyal" Then
MsgBox ("password,ok")
Else
MsgBox ("invalid password,try again")
End If
End Sub
Private Sub Command2_Click()
End
End Sub
OUTPUT
2.Write a program using cut, copy, paste and select all text boxes and
command button.
CODING

Dim abc As String


Private Sub Command1_Click()
Text2.Text = Text1.SelText
End Sub
Private Sub Command2_Click()
Text2.Text = Text1.SelLength
End Sub
Private Sub Command3_Click()
Text2.Text = Text1.SelStart
End Sub
Private Sub Command4_Click()
abc = Text1.Text
Text1.Text = ""
End Sub
Private Sub Command5_Click()
abc = Text1.Text
End Sub
Private Sub Command6_Click()
Text2.Text = abc
End Sub
Private Sub Command7_Click()
End
End Sub
OUTPUT
3.Write a program for tour travel agency.

CODING

Private Sub Option1_Click()


Check1.Value = 1
Check2.Value = 0
Check3.Value = 1
Check4.Value = 0
End Sub
Private Sub Option2_Click()
Check1.Value = 1
Check2.Value = 1
Check3.Value = 1
Check4.Value = 0
End Sub
Private Sub Option3_Click()
Check1.Value = 0
Check2.Value = 0
Check3.Value = 1
Check4.Value = 0
End Sub
OUTPUT
4.Write a program using checkboxes.

CODING

Private Sub Check1_Click()


If Check1.Value = 1 Then
Text1.Font.Bold = True
Else
Text1.Font.Bold = False
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then
Text1.Font.Italic = True
Else
Text1.Font.Italic = False
End If
End Sub
Private Sub Check3_Click()
If Check3.Value = 1 Then
Text1.Font.Underline = True
Else
Text1.Font.Underline = False
End If
End Sub
Private Sub Check4_Click()
If Check4.Value = 1 Then
Text1.Text = LCase(Text1.Text)
End If
End Sub

OUTPUT
5. Write a program using listbox.

CODING

Private Sub Command1_Click()


List1.AddItem Text1.Text
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Dim pos As Integer
pos = List1.ListIndex
If (pos >= 0) Then
List1.RemoveItem pos
End If
End Sub
Private Sub Command3_Click()
List1.Clear
End Sub
Private Sub Command4_Click()
End
End Sub
OUTPUT
6. Write a program using timer control.

CODING

Private Sub Timer1_Timer()


If Shape2.Visible Then
Command1.Caption = "Go"
Shape3.Visible = True
Shape1.Visible = False
Shape2.Visible = False
ElseIf Shape3.Visible Then
Command1.Caption = "Stop"
Shape3.Visible = False
Shape1.Visible = True
Shape2.Visible = False
ElseIf Shape1.Visible Then
Command1.Caption = "Ready"
Shape3.Visible = False
Shape2.Visible = True
Shape1.Visible = False
End If
End Sub
OUTPUT
7.Write a program using shape control and scrollbar control.

CODING

Private Sub HScroll1_Change()


Shape1.Width = HScroll1.Value
End Sub
Private Sub VScroll1_Change()
Shape1.Height = VScroll1.Value
End Sub
OUTPUT
8.Write a program using picture control.

CODING

Private Sub Option1_Click()


Picture1.Picture = LoadPicture("D:\wallpaper\Bike.jpg")
End Sub
Private Sub Option2_Click()
Picture1.Picture = LoadPicture("D:\wallpaper\Bear.jpg")
End Sub
Private Sub Option3_Click()
Picture1.Picture = LoadPicture("D:\wallpaper\Flower.jpg")
End Sub
Private Sub Option4_Click()
Picture1.Picture = LoadPicture("D:\wallpaper\Chutki
20141014_081756.jpg")
End Sub
OUTPUT
9.Write a program using imagebox control.

CODING

Private Sub Command1_Click()


Picture1 = Picture2
Picture2 = Picture3
Picture3 = Picture1
End Sub
OUTPUT
10. Write a program using directory, drive,and filebox.

CODING

Private Sub Dir1_Change()


File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_Click()
Dim s As String
s = Dir1.Path + "\" + File1.FileName
Text1.Text = s
End Sub
OUTPUT
11. Write a program using scrollbar control.

CODING

Dim faht As Integer


Dim celt As Integer
Private Sub VScroll1_Change()
faht = VScroll1.Value
Label2.Caption = Str(faht)
celt = (faht - 32) * 5 / 9
Label4 = Str(celt)
End Sub
Private Sub Command1_Click()
End
End Sub
OUTPUT

12. Write a program to change a color of text boxes using scrollbar.


CODING

Private Sub HScroll1_Change()


Text1.BackColor = RGB(VScroll1.Value, HScroll1.Value, 0)
End Sub
Private Sub VScroll1_Change()
Text1.BackColor = RGB(VScroll1.Value, HScroll1.Value, 0)
End Sub

OUTPUT
13. Write a program to find out maximum of three number.
CODING

Private Sub Command1_Click()


Dim n1 As Integer, n2 As Integer, n3 As Integer
n1 = Val(Text1.Text)
n2 = Val(Text2.Text)
n3 = Val(Text3.Text)
Max = maximum(n1, n2, n3)
If Max = 0 Then
MsgBox ("Two number are equal")
Else
MsgBox ("Maximum number is" & Str(Max))
End If
End Sub
Private Function maximum(num1 As Integer, num2 As Integer, num3 As
Integer)
If num1 = num2 = num3 Or num2 = num3 Then
Exit Function
End If
If num1 > num2 And num3 Then
maximum = num1
ElseIf num2 > num1 And num2 > num3 Then
maximum = num2
Else
maximum = num3
End If
End Function

OUTPUT

14. Write a program of call by value and call by reference.


CODING

Private Sub swapbyref(ByRef one As Integer, ByRef two As Integer)


Dim temp As Integer
temp = one
one = two
two = temp
End Sub
Private Sub swapbyvalue(ByVal one As Integer, ByVal two As Integer)
Dim temp As Integer
temp = one
one = two
two = temp
End Sub
Private Sub Command1_Click()
Dim first As Integer, sec As Integer
first = Val(Text1.Text)
sec = Val(Text2.Text)
Call swapbyvalue(first, sec)
Text3.Text = first
Text4.Text = sec
MsgBox ("Swap by value")
End Sub
Private Sub Command2_Click()
Dim first As Integer, sec As Integer
first = Val(Text1.Text)
sec = Val(Text2.Text)
Call swapbyref(first, sec)
Text3.Text = first
Text4.Text = sec
MsgBox ("Swap by reference"
End Sub

OUTPUT

15.Write a program to find even and odd using procedure.


CODING

Private Sub Command1_Click()


Dim n As Single
n = InputBox("Enter the number")
division (n)
End Sub
Sub division(a As Single)
If a Mod 2 = 0 Then
MsgBox ("Number is even")
Else
MsgBox ("Number is odd")
End If
End Sub
Private Sub Command2_Click()
End
End Sub

OUTPUT
16. Write a program to find factorial number using function.
CODING

Private Sub Command1_Click()


Dim n As Integer, i As Integer
List1.Clear
n = Val(Text1.Text)
For i = 0 To n
List1.AddItem factorial((i))
Next i
End Sub
Private Function factorial(n1 As Double) As Double
If n1 <= 1 Then
factorial = 1
Else
factorial = n1 * factorial(n1 - 1)
End If
End Function
Private Sub Command2_Click()
End
End Sub

OUTPUT
17.Write a program to display matrices using an array.
CODING

Dim b(1 To 5, 1 To 5) As Integer


Dim s(1 To 5, 1 To 5) As Integer
Dim i As Integer, j As Integer
Dim m As Integer, n As Integer
Private Sub Command1_Click()
m = Val(InputBox("Enter total rows"))
n = Val(InputBox("Enter total colomns"))
Print "order of matrices is" & m & " " & n
Print
Print "The elements of first matrices are"
For i = 1 To m
For j = 1 To na(i, j) = Val(InputBox("Enter element row# " & i & " column#
" & j))
Print a(i, j);
Next
Print
Next
Print
Print "The elements of second matrices are"
For i = 1 To m
For j = 1 To n
b(i, j) = Val(InputBox("Enter elements row# " & i & " column# " & j))
Print b(i, j);
Next
Print
Next
For i = 1 To m
For j = 1 To n
s(i, j) = a(i, j) + b(i, j)
Next
Next
Print
Print "The sum of two matrices are'"
For i = 1 To m
For j = 1 To n
Print s(i, j);
Next
Print
Next
End Sub
Private Sub Command2_Click()
End
End Sub

OUTPUT
18. Write a program to create a menu bar and display message using
messagebox.
CODING

Private Sub mnunew_Click()


MsgBox ("this is used for enter a new data")
End Sub
Private Sub mnusave_Click()
MsgBox ("this is used for save the data")
End Sub

STEPS TO CREATE MENU EDITOR SCREEN.

Start a new vb project and click on menu editor toolbar icon.the menu editor
screen display on screen.

Menu Editor Screen.


OUTPUT
19.Write a program to creating a popup of menubar.

CODING

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As


Single, Y As Single)
If Button = vbRightButton Then
PopupMenu mnuitems
End If
End Sub
Private Sub mnubold_Click()
If mnubold.Checked Then
Label1.FontBold = False
mnubold.Checked = False
Else
Label1.FontBold = True
mnubold.Checked = True
End If
End Sub
Private Sub mnucancel_Click()
End
End Sub
Private Sub mnuitalic_Click()
If mnuitalic.Checked Then
Label1.FontItalic = False
mnuitalic.Checked = False
Else
Label1.FontItalic = True
mnuitalic.Checked = True
End If
End Sub
Private Sub mnuunderline_Click()
If mnuunderline.Checked Then
Label1.FontUnderline = False
mnuunderline.Checked = False
Else
Label1.FontUnderline = True
mnuunderline.Checked = True
End If
End Sub
Menu Editor Screen.

OUTPUT
20.Write a program to print fibanoic series.

CODING

Private Sub Command1_Click()


Dim first As Integer, second As Integer, number As Integer
If Text1.Text = "" Then
MsgBox ("Enter the number")
Else
first = 0
second = 1
Print first
Print second
For i = 0 To (Val(Text1.Text) - 2)
number = first + second
Print number
first = second
second = number
Next i
End If
End Sub
OUTPUT
21.Write a program to show different colors using select case statement.

CODING

Dim scolor As String


Private Sub Command1_Click()
scolor = Text1.Text
Select Case scolor
Case Is = "red"
Label1.BackColor = vbRed
Case Is = "blue"
Label1.BackColor = vbBlue
Case Is = "green"
Label1.BackColor = vbGreen
Case Is = "yellow"
Label1.BackColor = vbYellow
Case Is = "black"
Label1.BackColor = vbBlack
Case Else
Label1.BackColor = vbWhite
Label1.Caption = "unknown color"
End Select
End Sub
Private Sub Form_Load()
Text1.Text = ""
End sub
OUTPUT

22.Write a program to print sum of series using do while loop.


CODING

Private Sub Text1_Change()


Dim num As Integer, sum As Integer, count As Integer
num = InputBox("Enter the number")
count = 0
sum = 0
sum = sum + num
Do While num <> 0
num = InputBox("Enter a number to continue and 0 to quit")
sum = sum + num
count = count + 1
Loop
MsgBox (count & "Number entered and their sum is " & sum)
End Sub

OUTPUT
23.Write a program to show a pyramid.

CODING

Private Sub Command1_Click()


Dim x As Integer, y As Integer
For x = Asc("1") To Asc("9")
For y = Asc("1") To x
Print Chr(y);
Next y
Print
Next x
End Sub

OUTPUT
24.Write a program to design a calculator using a control array.
CODING

Dim op1 As Double


Dim op2 As Double
Dim operator As String
Dim result As Double
Private Sub Command1_Click(Index As Integer)
Text1.Text = Text1.Text & Command1(Index).Caption
op1 = Val(Text1.Text)
End Sub
Private Sub Command2_Click(Index As Integer)
Text1.Text = ""
op2 = op1
op1 = 0
operator = Command2(Index).Caption
End Sub
Private Sub Command3_Click()
op2 = 0
op1 = 0
Text1.Text = ""
End Sub
Private Sub Command4_Click()
op1 = 0
Text1.Text = ""
End Sub
Private Sub Command5_Click()
Select Case operator
Case "+"
result = op2 + op1
Text1.Text = result
Case "-"
result = op2 - op1
Text1.Text = result
Case "*"
result = op2 * op1
Text1.Text = result
Case "/"
result = op2 / op1
Text1.Text = result
End Select
op1 = result
End Sub
Private Sub Command6_Click()
Text1.Text = Val(Sqr(op1))
End Sub
OUTPUT

25.Write a program using listbox.(Indian and Australia team).


CODING

Private Sub Command3_Click()


Dim n As Integer
Dim s As String
n = InputBox("How many name you want to enter")
For i = 0 To n Step 1
s = InputBox("Enter the name of indian")
List1.AddItem s
Next
End Sub
Private Sub Command4_Click()
Dim i As Integer
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then
List1.RemoveItem List1.ListIndex
End If
Next
End Sub
Private Sub Command5_Click()
Dim n As Integer
Dim s As String
n = InputBox("How many name you want to enter")
For i = 0 To n Step 1
s = InputBox("Enter the name of australian")
List2.AddItem s
Next
End Sub
Private Sub Command6_Click()
Dim i As Integer
For i = List2.ListCount - 1 To 0 Step -1
If List2.Selected(i) Then
List2.RemoveItem List2.ListIndex
End If
Next
End Sub
Private Sub Command7_Click()
End
End Sub

OUTPUT
26.Write a program to design a resturant application
CODING

Private Sub Command1_Click()


End
End Sub
Private Sub Form_Load()
Option1.Value = False
Option2.Value = False
End Sub
Private Sub Option1_Click()
If Option1.Value = True Then
Form34.Show
form35.Hide
End If
End Sub

Private Sub Option2_Click()


If Option2.Value = True Then
Form34.Hide
form35.Show
End If
End Sub

When click on indian


CODING

Dim var1, var2, var3, var4 As Double


Private Sub Command1_Click()
If Check1.Value = 1 Then
var1 = Label5.Caption
var2 = Text1.Text
var3 = var1 * var2
Text5.Text = var3
var3 = Text1.Text * Label5.Caption
End If
If Check2.Value = 1 Then
var1 = Label6.Caption
var2 = Text2.Text
var3 = var1 * var2
Text6.Text = var3
End If
If Check3.Value = 1 Then
var1 = Label7.Caption
var2 = Text3.Text
var3 = var1 * var2
Text7.Text = var3
End If
If Check4.Value = 1 Then
var1 = Label8.Caption
var2 = Text4.Text
var3 = var1 * var2
Text8.Text = var3
End If
var4 = Val(Text5.Text) + Val(Text6.Text) + Val(Text7.Text) +
Val(Text8.Text)
Text9.Text = var4
End Sub

When click on chinese .


OUTPUT
Indian restaurant menu

Chinese restaurant menu.

27.Write a program to define a ODBC steps.


A)Goto control panel and click on administrative tools and then click on
ODBC.

B)Click on Driver do microsoft access (*.mdb) and click on finish button.


C) ODBC Microsoft Accesss setup dialog box appears,give datasource
name and click on select button to select the database.
D)Click ok,ODBC Microsoft access setup dialog box appear again click on
ok.
\

E)click on ok and ODBC data source administrator appears,name of ODBC


appears on user data sources and click on close button
2.Steps for connectivity through ADODC
a)OpenVB standard EXE project.
b)Clickon project menu and click on Components to open.
c)Select Microsoft ADO control (OLEDB) and click on apply then ok.
28.This will add ADODC in the toolbox.

d)Design the form ,place ADODC on form Setting Connection.


e)Right click on ADODC ,select properties.This will open property page
window of ADODC.

f)Select general tab ,Select use Connection String.click on build button of


connection string.this will open data link property window.
g) As your DB is made in access thus select provider ‘Microsoft jet 4.0 OLE
DB provider’ from the provider tab and click on next button.
h)This will open the connection tab.under connection tab select the DB
which you want to connect with a projecti.e company.

Click on Test Connection.


i)Wait for message”test connection succeeded”,click ok.
j)Select Record Source tab.

k)Click on apply and then ok Attach form with different attributes of table.
l) Now ,one by one bind every textbox with their respective attribute name
of MS-access.For this select textbox,set its Data sorce property to ADODC
And select respective attribute from dropdown list of data
field property.
j)Click on Run menu..
29.Write a program to Make an application using ADODC control.

Coding:

Private Sub Command1_Click()


Adodc1.Recordset.AddNew
End Sub
Private Sub Command2_Click()
Adodc1.Recordset.Delete
End Sub
Private Sub Command3_Click()
On Error GoTo message
Adodc1.Recordset.MoveFirst
Exit Sub
message:
Adodc1.Recordset.MoveFirst
End Sub
Private Sub Command6_Click()
On Error GoTo message
Adodc1.Recordset.MoveLast
Exit Sub
message:
Adodc1.Recordset.MoveLast
End Sub
Private Sub Command6_Click()
Adodc1.Recordset.Fields("Stuid").Value = Text1.Text
Adodc1.Recordset.Fields("Stu name”).Value = Text2.Text
Adodc1.Recordset.Fields("Stu course”).Value = Text3.Text
Adodc1.Recordset.Update
Adodc1.Refresh
End Sub
Private Sub Command7_Click()
On Error GoTo message
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveFirst
Else
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveFirst
End If
End If
Exit Sub
message:
Adodc1.Recordset.MoveFirst
End Sub
Private Sub Command5_Click()
On Error GoTo message
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveLast
Else
Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF Then
Adodc1.Recordset.MoveLast
End If
End If
Exit Sub
message:
Adodc1.Recordset.MoveLast
End Sub
Private Sub Command8_Click()
Adodc1.Recordset.Update
End Sub
Output
30.Write a program to Make an application using Active X control.

a)open new project using active control form.It will create a user
control,usercontrol1.
b)design the userdefine activeX control .

CODING

Private Sub Command1_Click()


Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub

d)click on file menu.click on save project as dialog box appears..


make a folder name as active x and save the project in active folder
e)To register an active X control,click on File menu and select the make
pro.ocx option .

f)Project saved as .ocx and finally click on ok.


Use your own active control.
After creating and registering activeX control ,we can use it like the
other controls.
a)open the new project using standard exe form.
b)Go to project menu,click on components menu,components dialog box
appears.

c)click on browse button and add active X control i.e project1 and then click
on apply and ok button.
d)new active control appears on the toolbar .

e)choose the user control1 from the list of controls in the toolbox.place the
control on the form.
f)Finally ,click on run button and see the output.

You might also like