Question (1) :-Answer
Question (1) :-Answer
Answer:-
Form Layout
Page 1
Name:-
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 2
Name:-
Question (2):-WAP to take input of principal, rate & time and calculate simple
interest & compound interest.
Answer:-
Form Layout
Page 3
Name:-
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
End Sub
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 4
Name:-
Answer:-
Form Layout
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 5
Name:-
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 6
Name:-
Question (4):- Design an interface, which will appear like mark sheet. It will
take input of marks in five subjects and calculate total marks and percentage then
provide grade according to following criteria. (Using nested if) ( Use tab index
property to move focus ).
If %
Then Grade
> = 90
A+
> = 75 & < 90
A
> = 60 & < 75
B
> = 45 & < 60
C
Otherwise
F
Answer:Form Layout
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 7
Name:-
Page 8
Name:-
Label11.Caption = ""
End Sub
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 9
Name:-
Question (5):- WAP to illustrate all functionalities of list box and combo box.
Answer:Form Layout
End Sub
Private Sub cmdclearlist_Click()
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 10
Name:-
List1.Clear
End Sub
Private Sub cmdexit_Click()
End
End Sub
Private Sub cmdremoveitem2_Click()
On Error Resume Next
List1.RemoveItem List1.ListIndex
End Sub
Private Sub cmdrermoveitem1_Click()
On Error Resume Next
Combo1.RemoveItem Combo1.ListIndex
End Sub
Private Sub Command1_Click()
Combo1.Clear
End Sub
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 11
Name:-
Answer:-
Form Layout
Page 12
Name:-
Text1.FontBold = True
Else
Text1.FontBold = False
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = vbChecked Then
Text1.FontItalic = True
Else
Text1.FontItalic = False
End If
End Sub
Private Sub Check3_Click()
If Check3.Value = vbChecked Then
Text1.FontUnderline = True
Else
Text1.FontUnderline = False
End If
End Sub
Private Sub Check4_Click()
If Check4.Value = 1 Then
Check5.Value = 0
Check6.Value = 0
Text1.FontSize = 8
Else
Text1.FontSize = 8
End If
End Sub
Private Sub Check5_Click()
If Check5.Value = 1 Then
Check4.Value = 0
Check6.Value = 0
Text1.FontSize = 12
Else
Text1.FontSize = 8
End If
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 13
Name:-
End Sub
Private Sub Check6_Click()
If Check6.Value = 1 Then
Check4.Value = 0
Check5.Value = 0
Text1.FontSize = 14
Else
Text1.FontSize = 8
End If
End Sub
Private Sub Check7_Click()
If Check7.Value = 1 Then
Check8.Value = 0
Check9.Value = 0
Text1.ForeColor = vbRed
ElseIf Check7.Value = 0 And Check8.Value = 0 And Check9.Value = 0 Then
End If
End Sub
Private Sub Check8_Click()
If Check8.Value = 1 Then
Check7.Value = 0
Check9.Value = 0
Text1.ForeColor = vbBlue
ElseIf Check7.Value = 0 And Check8.Value = 0 And Check9.Value = 0 Then
Text1.ForeColor = vbResCursor
End If
End Sub
Private Sub Check9_Click()
If Check9.Value = 1 Then
Check8.Value = 0
Check7.Value = 0
Text1.ForeColor = vbGreen
ElseIf Check7.Value = 0 And Check8.Value = 0 And Check9.Value = 0 Then
Text1.ForeColor = vbResCursor
End If
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 14
Name:-
End Sub
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 15
Name:-
Question (7):- WAP to change back color of any control (label, textbox) using
scroll box.
Answer:-
Form Layout
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 16
Name:-
Question (8):- WAP to search an element for a one dimension static array.
Answer:-
Form Layout
Page 17
Name:-
Else
Print "element found at" & pos; , "position"
End If
End Sub
Private Sub Command2_Click()
i=0
For i = 1 To 5 Step 1
a(i) = Input Box("enter array elements")
Print "element =" & a(i)
Print
Next i
End Sub
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 18
Name:-
Question (9):- WAP to illustrate call by value and call by reference ( to swap to
values).
Answer:-
Form Layout
Page 19
Name:-
Text4.Text = b
End Sub
Private Sub swapr(ByRef a As Integer, ByRef b As Integer)
t=a
a=b
b=t
Text3.Text = a
Text4.Text = b
End Sub
Private Sub Command1_Click()
x = Val(Text1.Text)
y = Val(Text2.Text)
Call swapv(x, y)
Print x
Print y
End Sub
Private Sub Command2_Click()
x = Val(Text1.Text)
y = Val(Text2.Text)
Call swapr(x, y)
Print x
Print y
End Sub
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 20
Name:-
Answer:Form Layout
Coding section
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 21
Name:-
Dim n As Integer
Dim d As Integer
Private Sub Command1_Click()
n = InputBox("enter no.", "processing", "0")
d = fact(n)
Text1.Text = d
End Sub
Public Function fact(num As Integer) As Integer
If num <= 1 Then
fact = 1
Else
fact = num * fact(num - 1)
End If
End Function
Private Sub Command2_Click()
Text1.Text = ""
End Sub
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 22
Name:-
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 23
Name:-
Output:Steps Before
Go to Project Menu
Click on Component command
In the component dialog box select control tab if not selected
1.
Check the Microsoft ADO Data Control 6.0
2.
Drag the ADO Control on the form
3.
Right Click on the Control Select Property
4.
Select Data Base Path. Test Connection press OK
5.
Property Pages go to Record Source Tab an set following
Properties:
Command Type = CMDTABLE
Table Name = studentrecord (Name of the table)
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 24
Name:-
Output:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 25
Name:-
Coding:
Dim n%, i%
Private Sub Command1_Click()
n = InputBox("enter number that you want to check Prime on not")
For i = 2 To n - 1 Step 1
If n Mod i = 0 Then
Exit For
End If
Next i
If (n = i) Then
MsgBox ("prime number")
Else
MsgBox ("not prime number")
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Output:
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 26
Name:-
C:\Program Files\vb1.prj
B.Com-III
MAHANT LAXMINARAYAN DAS COLLEGE
Page 27