You are on page 1of 94

INDEX

NAME OF DATE OF DATE OF


SL.NO. SIGNATURE
ASSIGNMENT ASSIGNMENT SUBMISSION
1. ASSIGNMENT - 1
2. ASSIGNMENT -2
3. ASSIGNMENT -3
4. ASSIGNMENT -4
5. ASSIGNMENT -5
6. ASSIGNMENT -6
7. ASSIGNMENT -7
8. ASSIGNMENT -8
9. ASSIGNMENT -9
10. ASSIGNMENT -10
11. ASSIGNMENT -11
12. ASSIGNMENT -12
13. ASSIGNMENT -13
14. ASSIGNMENT -14
15. ASSIGNMENT -15
16. ASSIGNMENT -16
17. ASSIGNMENT -17
18. ASSIGNMENT -18
19. ASSIGNMENT -19
20. ASSIGNMENT -20
21. ASSIGNMENT -21
22. ASSIGNMENT -22
23. ASSIGNMENT -23
24. ASSIGNMENT -24
25. ASSIGNMENT -25
26. ASSIGNMENT -26
27. ASSIGNMENT -27
28. ASSIGNMENT -28
29. ASSIGNMENT -29
30. ASSIGNMENT -30
31. ASSIGNMENT -31
Assignment 1 : WAP to perform arithmetic operation using command buttons ( Declare variable globally).
Form Design

Form & Object Properties

Control Properties Setting

Form Name Assignment1

Font MS Sans Serif, Regular, 14

Caption Assignment 1 Developed by- SSMV , Date 17-08-2012

Label 1 Name lblno1

Caption Enter First Number

Label 2 Name lblno2

Caption Enter Second Number

Label 3 Name lbl3

Caption Result

Label 4 Name lblresult

Caption

Appearance 0-Flat

TextBox 1 Name Txtno1

text
TextBox 2 Name Txtno2

text

CommandButton 1 Name cmdadd

Caption +

CommandButton 2 Name cmdsub

Caption -

CommandButton 3 Name cmdmul

Caption *

CommandButton 4 Name cmddiv

Caption /

CommandButton 5 Name cmdclose

Caption CLOSE

Code Window

Dim sum, subt, mul, div As Double

Private Sub cmdadd_Click()


sum = Val(txtno1.Text) + Val(txtno2.Text)
lblresult.Caption = sum
End Sub

Private Sub cmdclose_Click()


End
End Sub

Private Sub cmddiv_Click()


div = Val(txtno1.Text) / Val(txtno2.Text)
lblresult.Caption = div
End Sub

Private Sub cmdmul_Click()


mul = Val(txtno1.Text) * Val(txtno2.Text)
lblresult.Caption = mul
End Sub

Private Sub cmdsub_Click()


subt = Val(txtno1.Text) - Val(txtno2.Text)
lblresult.Caption = subt
End Sub
Output

Assignment 2 : WAP to take input of principal, rate, & time and calculate simple interest & compound interest.
Form Design

Form & Object Properties


Control Properties Setting

Form Name Assignment2

Font MS Sans Serif, Regular, 14

Caption Assignment 2 Developed by- SSMV , Date 17-08-2012

Label 1 Name Lblprincipal


Caption Enter amount of principal

Label 2 Name lblrate

Caption Enter percent of rate

Label 3 Name lbltime

Caption Enter duration of time

Label 4 Name lblinterest

Caption

Label 5 Name lbltotal

Caption Total Amount ( In Rs.)

Label 6 Name lblinterestans

Caption

Appearance 0-Flat

Label 7 Name lbltotalans

Caption

Appearance 0-Flat

TextBox 1 Name Txtprincipal

text

TextBox 2 Name Txtrate

text

TextBox 3 Name Txttime

text

CommandButton 1 Name cmdsimple

Caption Simple Interest


CommandButton 2 Name cmdcompound

Caption Compound Interest

CommandButton 3 Name cmdclose

Caption CLOSE

Code Window

Dim p, r, t, simple, compound As Double

Private Sub cmdclose_Click()


End
End Sub

Private Sub cmdcompound_Click()


compound = p * ((1 + (r / 100)) ^ t)
lblinterestans.Caption = Round((compound - p), 2)
lblinterest.Caption = "Compound Interest"
lbltotalans.Caption = Round(compound, 2)
End Sub

Private Sub cmdsimple_Click()


p = Val(txtprincipal.Text)
r = Val(txtrate.Text)
t = Val(txttime.Text)
simple = p * r * t / 100
lblinterestans.Caption = simple
lblinterest.Caption = "Simple Interest"
lbltotalans.Caption = p + simple
End Sub

Output
Assignment 3 : Write a program to take input of x and print table of x in the following format.
X*1=X
X * 2 = 2X
-----------
-----------
X * 10 = 10*X

Form Design

Form & Object Properties

Control Properties Setting

Form Name Assignment3

Font MS Sans Serif, Regular, 14

Caption Assignment 3 Developed by- SSMV , Date 31-08-2012

Label 1 Name lblno

Caption Enter number for table

TextBox 1 Name Txtno

text

CommandButton 1 Name cmdtable

Caption Generate table

CommandButton 3 Name cmdexit


Caption EXIT

Code Window

Private Sub cmdexit_Click()


End
End Sub
___________________________________

Private Sub Cmdtable_Click()


Dim x, y As Integer
assignment3.Cls ' Clear the form contain
x = Val(txtno.Text)
For y = 1 To 10 Step 1
Print x; "*"; y; " = "; x * y
Next
End Sub

Output
Assignment 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

Form Design

Lblstname

Lblrollno

Lbltmarks

Lblpercent

Lblresult

Lblgrade
Form & main Object Properties

Control Properties Setting

Form Name Assignment4

Font MS Sans Serif, Regular, 14

Caption Assignment 4 Developed by- SSMV , Date 07-09-2012

Label Name lblname

Caption Name of student

Label Name lblrollno

Caption Roll Number

Label Name lbltmarks

Caption

Label Name lblpercent

Caption

Label Name lblresult

Caption

Label Name lblgrade

Caption

Text 1 Name Txtname

caption

TabIndex 1

Text 2 Name Txtrollno

caption

TabIndex 2

Text 3 Name Txtmarks1

caption

TabIndex 3

Text 4 Name Txtmarks2


caption

TabIndex 4

Text 5 Name Txtmarks3

caption

TabIndex 5

Text 6 Name Txtmarks4

caption

TabIndex 6

Text 7 Name Txtmarks5

caption

TabIndex 7

CommandButton 1 Name Cmdshowresult

Caption Show Result

TabIndex 8

CommandButton 2 Name cmdclose

Caption Close

TabIndex 9

Code Window
Private Sub cmdclose_Click()
End
End Sub

Private Sub cmdshowresult_Click()


Dim marks1, marks2, marks3, marks4, marks5 As Integer
Dim total, percent As Single
marks1 = Val(txtmarks1.Text)
marks2 = Val(Txtmarks2.Text)
marks3 = Val(txtmarks3.Text)
marks4 = Val(txtmarks4.Text)
marks5 = Val(txtmarks5.Text)

total = marks1 + marks2 + marks3 + marks4 + marks5


percent = Round((total / 4), 2)

lblmarks.Caption = total
lblpercent.Caption = percent

If percent >= 45 Then


lblresult.Caption = "Pass"
If percent >= 90 Then
lblgrade.Caption = "A+"
ElseIf percent >= 75 And percent < 90 Then
lblgrade.Caption = "A"
ElseIf percent >= 60 And percent < 75 Then
lblgrade.Caption = "B"
ElseIf percent >= 45 And percent < 60 Then
lblgrade.Caption = "C"
End If
Else
lblresult.Caption = "Fail"
lblgrade.Caption = "F "
End If
End Sub

Output

Assignment 5 : WAP to create a simple calculator (Using control array)


Form Design

Form & Object Properties

Control Properties Setting

Form Name frmcalculator

Font MS Sans Serif, Regular, 14

Caption Assignment 5 (Calculator) by - SSMV

BorderStyle 1-Fixed Single

MaxButton False

Text Name txtoutput

Alignment 1-Right Justify

Text

CommandButton1 Name cmdno

Caption 0

Index 0

CommandButton2 Name cmdno

Caption 1
Index 1

CommandButton3 Name cmdno

Caption 2

Index 2

CommandButton4 Name cmdno

Caption 3

Index 3

CommandButton5 Name cmdno

Caption 4

Index 4

CommandButton6 Name cmdno

Caption 5

Index 5

CommandButton7 Name cmdno

Caption 6

Index 6

CommandButton8 Name cmdno

Caption 7

Index 7

CommandButton9 Name cmdno

Caption 8

Index 8

CommandButton10 Name cmdno

Caption 9

Index 9

CommandButton11 Name cmdno


Caption .

Index 10

CommandButton12 Name cmdoperator

Caption +

Index 0

CommandButton13 Name cmdoperator

Caption -

Index 1

CommandButton14 Name cmdoperator

Caption *

Index 2

CommandButton15 Name cmdoperator

Caption /

Index 3

CommandButton16 Name cmdclear

Caption C

CommandButton17 Name cmdequal

Caption =

Code Window

Private LastOperator As String


Private FirstPart As String

Private Sub cmdClear_Click()


FirstPart = ""
LastOperator = ""
txtoutput.Text = ""
End Sub

Private Sub cmdEqual_Click()


Select Case LastOperator
Case Is = "+"
txtoutput.Text = Val(FirstPart) + Val(txtoutput.Text)
Case Is = "-"
txtoutput.Text = Val(FirstPart) - Val(txtoutput.Text)
Case Is = "/"
If Val(txtoutput.Text) = 0 Then
MsgBox "Can't divide by ziro.", 48, "Calculator"
Else
txtoutput.Text = Val(FirstPart) / Val(txtoutput.Text)
End If
Case Is = "*"
txtoutput.Text = Val(FirstPart) * Val(txtoutput.Text)
End Select
FirstPart = ""
LastOperator = ""
End Sub

Private Sub cmdOperator_Click(Index As Integer)


LastOperator = cmdoperator(Index).Caption
FirstPart = txtoutput.Text
txtoutput.Text = ""
End Sub

Private Sub Cmdno_Click(Index As Integer)


txtoutput.Text = txtoutput.Text + cmdno(Index).Caption
End Sub

Output
Assignment 6 : Write a program to check whether an centered no. is prime or not. (Using for loop & Exit for)

Form Design

Form & Object Properties

Control Properties Setting

Form Name frmprime

Font MS Sans Serif, Regular, 14

Caption Assignment 6 ,Devleped by – SSMV,Date-21.09.2012

BorderStyle 1-Fixed Single

Text Name txtno

Text

Label 1 Name lblno

Caption Enter no. for test prime or not.

Label2 Name lblans

Caption

Appearance 0-Flat

CommandButton1 Name cmdtest

Caption Test

CommandButton2 Name cmdclear

Caption Clear

CommandButton3 Name cmdclose


Caption Close

Code Window

Private Sub cmdclear_Click()


txtno.Text = ""
lblans.Caption = ""
End Sub
_________________________________________________
Private Sub cmdclose_Click()
End
End Sub
__________________________________________________

Private Sub cmdtest_Click()


Dim x, y, t As Integer
x = Val(txtno.Text)

If x = 1 Or x = 2 Then
t=0
Else
For y = 2 To (x - 1)
If x Mod y = 0 Then
t=1
Exit For
End If
Next y
End If
If t = 1 Then
lblans.Caption = " It is not a prime number."
Else
lblans.Caption = " It is a prime number."
End If
If x <= 0 Then
txtno.Text = ""
lblans.Caption = ""
End If
End Sub

Output
Assignment 7 : Write a program which will count all vowels, consonants, digits, special characters and blank
spaces in a sentences (Using select case) .

Form Design

Form & Object Properties

Control Properties Setting

Form Name Assignment7

Font MS Sans Serif, Regular, 14

Caption Assignment 7 ,Devleped by – SSMV,Date-28.09.2012

BoarderStyle 3-Fixed Dialog

Text Name txtsentence

Text

Label Name lblvowel

Caption

Appearance 0-Flat

Label Name lblconsonant

Caption

Appearance 0-Flat
Label Name lbldigit

Caption

Appearance 0-Flat

Label Name lblspchar

Caption

Appearance 0-Flat

Label Name lblspace

Caption

Appearance 0-Flat

CommandButton1 Name cmdcheck

Caption CHECK

CommandButton2 Name cmdclear

Caption Clear

CommandButton3 Name cmdclose

Caption CLOSE

Code Window
Private Sub cmdcheck_Click()
Dim sentence, txt As String
Dim v, c, d, sc, s, l As Integer
sentence = txtsentence.text
l = Len(sentence)
For i = 1 To l
txt = Mid(sentence, i, 1)
Select Case LCase(txt)
Case "a", "e", "i", "o", "u"
v=v+1
Case 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
d=d+1
Case " "
s=s+1
Case "!", "@", "#", "$", "%", "^", "&", "*", "<", ">", "?","/", "\", "-",”,”,”.”
sc = sc + 1
Case Else ' Count Consonants
c=c+1
End Select
Next i
lblvowel.Caption = v
lblconsonant.Caption = c
lbldigit.Caption = d
lblspchar.Caption = sc
lblspace.Caption = s
End Sub
Private Sub cmdclear_Click()
txtsentence.text = ""
lblvowel.Caption = ""
lblconsonant.Caption = ""
lbldigit.Caption = ""
lblspchar.Caption = ""
lblspace.Caption = ""
End Sub
Private Sub cmdclose_Click()
End
End Sub

Output

Assignment 8 : WAP to illustrate all


functionalities of listbox and
combobox.

Form Design
Form & Main Object Properties

Control Properties Setting

Form Name Assignment8

Font MS Sans Serif, Regular, 14

Caption Assignment 8 ,Devleped by – SSMV,Date-05.10.2012

BoarderStyle 3-Fixed Dialog

Text1 Name txtstname

Text

Text2 Name txtcourse

Text

ListBox Name Lststname

ComboBox Name Cbocourse

CommandButton1 Name Cmdladd

Caption ADD

CommandButton2 Name Cmdlclear

Caption CLEAR

CommandButton3 Name Cmdlremove

Caption REMOVE

CommandButton4 Name cmdlsort

Caption SORT

CommandButton5 Name cmdcadd

Caption ADD

CommandButton6 Name Cmdcclear


Caption CLEAR

CommandButton7 Name Cmdcremove

Caption REMOVE

CommandButton8 Name cmdcsort

Caption SORT

Code Window

Private Sub cmdladd_Click()


Dim stname As String
stname = txtstname.Text
If stname = "" Then
MsgBox ("Please enter student name")
Else
lststname.AddItem stname
txtstname.Text = ""
txtstname.SetFocus
End If
End Sub
___________________________________
Private Sub cmdlclear_Click()
lststname.Clear
txtstname.SetFocus
End Sub
_________________________________________
Private Sub cmdlremove_Click()
If lststname.ListIndex = -1 Then
MsgBox ("Please select student name")
Else
lststname.RemoveItem (lststname.ListIndex)
End If
End Sub
___________________________________________
Private Sub cmdlsort_Click()
L = lststname.ListCount
For i = 0 To L - 1
For j = i + 1 To L - 1
If lststname.List(i) > lststname.List(j) Then
Temp = lststname.List(i)
lststname.List(i) = lststname.List(j)
lststname.List(j) = Temp
End If
Next
Next
End Sub
_____________________________________________
Private Sub cmdcadd_Click()
Dim coursename As String
coursename = txtcourse.Text
If coursename = "" Then
MsgBox ("Please enter Course name.")
Else
cbocourse.AddItem coursename
txtcourse.Text = ""
txtcourse.SetFocus
End If
End Sub
____________________________________________
Private Sub cmdcclear_Click()
cbocourse.Clear
txtcourse.SetFocus
End Sub
___________________________________________
Private Sub cmdcremove_Click()
If cbocourse.ListIndex = -1 Then
MsgBox ("Please select course name")
Else
cbocourse.RemoveItem (cbocourse.ListIndex)
End If
End Sub
_______________________________________________
Private Sub cmdcsort_Click()
L = cbocourse.ListCount
For i = 0 To L - 1
For j = i + 1 To L - 1
If cbocourse.List(i) > cbocourse.List(j) Then
Temp = cbocourse.List(i)
cbocourse.List(i) = cbocourse.List(j)
cbocourse.List(j) = Temp
End If
Next
Next
End Sub
______________________________________________
Output

Assignment 9 : WAP using check


boxes for following font effects.
Bold
Italic
Underline
Increase font size
Decrease font size
Font color

Form Design

Form & Main Object Properties

Control Properties Setting


Form Name Assignment9

Font MS Sans Serif, Regular, 14

Caption Assignment 9 ,Devleped by – SSMV,Date-05.10.2012

BoarderStyle 3-Fixed Dialog

Text1 Name Txt1

Text

CheckBox1 Name chkbold

Caption Bold

CheckBox2 Name chkItalic

Caption Italic

CheckBox3 Name chkunderline

Caption Underline

CheckBox4 Name chkfontincrease

Caption Increase font size

CheckBox5 Name chkfontdecrease

Caption Increase font size

CheckBox6 Name chkfontcolor

Caption font color

Code Window

Dim fsize As Integer


______________________
Private Sub chkbold_Click()
If chkbold.Value = 1 Then
txt1.FontBold = True
Else
txt1.FontBold = False
End If
End Sub
__________________________
Private Sub chkitalic_Click()
If chkitalic.Value = 1 Then
txt1.FontItalic = True
Else
txt1.FontItalic = False
End If
End Sub
_________________________________
Private Sub chkunderline_Click()
If chkunderline.Value = 1 Then
txt1.FontUnderline = True
Else
txt1.FontUnderline = False
End If
End Sub
_________________________________
Private Sub chkfontincrease_Click()
If chkfontincrease.Value = 1 Then
txt1.FontSize = txt1.FontSize + 4
Else
txt1.FontSize = fsize
End If
End Sub
________________________________
Private Sub chkfontdecrease_Click()
If chkfontdecrease.Value = 1 Then
txt1.FontSize = txt1.FontSize - 4
Else
txt1.FontSize = fsize
End If
End Sub
___________________________________
Private Sub txt1_Change()
fsize = txt1.FontSize
End Sub
_____________________________
Private Sub chkfontcolor_Click()
If chkfontcolor.Value = 1 Then
txt1.ForeColor = &HFF&
Else
txt1.ForeColor = &H80000012
End If
End Sub

Output
Assignment 10 : WAP for temperature
conversion using option button.

Form Design
Form & Object Properties

Control Properties Setting

Form Name Assignment10

Font MS Sans Serif, Regular, 14

Caption Assignment 10 Developed by- SSMV , Date 12-10-2012

BorderStyle 1-fixed Single

Label 1 Name Lbl1

Caption Enter temperature value

Label 2 Name lbltemp

Caption

Appearance 0-flat

Text1 Name Txttemp

Caption

OptionButton1 Name Optcen

Caption Centigrade

OptionButton1 Name Optfah

Caption Fahrenheit

Code Window

Dim temp As Integer ‘Declaration as global variable


___________________________________
Private Sub Optcen_Click()
If Optcen.Value = True Then
lbltemp.Caption = (5 / 9) * (temp - 32)
Else
lbltemp.Caption = ""
End If
End Sub
______________________________________
Private Sub Optfah_Click()
If Optfah.Value = True Then
lbltemp.Caption = ((9 * temp) / 5) + 32
Else
lbltemp.Caption = ""
End If
End Sub
_________________________________________
Private Sub txttemp_Change()
temp = Val(txttemp.Text)
Optcen.Value = False
Optfah.Value = False
lbltemp.Caption = ""
End Sub

Output
Assignment 11 : WAP to launch a rocket using pictures box and timer control.

Form Design

Form & Main Object Properties

Control Properties Setting

Form Name Assignment11

Font MS Sans Serif, Regular, 14

Caption Assignment 11 ,Devleped by – SSMV,Date-12.10.2012

BoarderStyle 3-Fixed Dialog

Label Name lblcountdown


Caption

Font MS Sans Serif, Regular, 100

PictureBox Name PicRocket

Picture Select path of picture of rocket ( Example C:\rocket.bmp )

BoarderStyle 0-None

Timer Name Tmr1

Interval 0

Enabled False

CommandButton Name cmdlaunch

Caption Launch Rocket

Code Window

Private Sub cmdlaunch_Click()


tmr1.Enabled = True
lblcountdown.Caption = 10
tmr1.Interval = 1000
End Sub
______________________________________________________
Private Sub tmr1_Timer()
If Val(lblcountdown.Caption) > 0 Then
lblcountdown.Caption = Val(lblcountdown.Caption) - 1
Else
lblcountdown.Caption = ""
tmr1.Interval = 50
PicRocket.Top = PicRocket.Top - 100
End If
End Sub

Output
Assignment 12 : WAP to
change back color of any control
(label , textbox) using scroll
box.
Form Design
Form & Object Properties

Control Properties Setting

Form Name Assignment12

Font MS Sans Serif, Regular, 14

Caption Assignment 12 Developed by- SSMV , Date 19-10-2012

BorderStyle 1-fixed Single

Label Name Lblname

Caption Enter your college name

Label Name lblR

Caption Red

Label Name lblG

Caption Green

Label Name lblB

Caption Blue

Text1 Name Txtname

Text Shri Shankaracharya Mahavidyalya

CheckBox1 Name ChkLabel

Caption Label

Value 0 - Unchecked

CheckBox2 Name ChkText

Caption Text

Value 0 - Unchecked

HscrollBar1 Name HsbR


Min 0

Max 255

LargeChange 10

SmallChange 1

HscrollBar2 Name HsbG

Min 0

Max 255

LargeChange 10

SmallChange 1

HscrollBar3 Name HsbB

Min 0

Max 255

LargeChange 10

SmallChange 1

Code Window

Dim red, green, blue As Integer ‘ Global Variable Declaration


_____________________________________________
Private Sub Chklabel_Click()
Lblname.BackColor = RGB(red, green, blue)
End Sub
________________________________________________
Private Sub Chktext_Click()
txtname.BackColor = RGB(red, green, blue)
End Sub
_____________________________________________
Private Sub HsbB_Change()
blue = HsbB.Value
LblB.Caption = "Blue = " & HsbB.Value
If Chklabel.Value = 1 Then
Lblname.BackColor = RGB(red, green, blue)
End If
If Chktext.Value = 1 Then
txtname.BackColor = RGB(red, green, blue)
End If
End Sub
_______________________________________________
Private Sub HsbG_Change()
green = HsbG.Value
LblG.Caption = "Green = " & HsbG.Value
If Chklabel.Value = 1 Then
Lblname.BackColor = RGB(red, green, blue)
End If
If Chktext.Value = 1 Then
txtname.BackColor = RGB(red, green, blue)
End If
End Sub
_______________________________________________
Private Sub HsbR_Change()
red = HsbR.Value
LblR.Caption = "Red = " & HsbR.Value
If Chklabel.Value = 1 Then
Lblname.BackColor = RGB(red, green, blue)
End If
If Chktext.Value = 1 Then
txtname.BackColor = RGB(red, green, blue)
End If
End Sub

Output
Assignment 13 : WAP to search an element for a “one dimension static array”.

Form Design

Form & Object Properties

Control Properties Setting

Form Name Assignment13

Font MS Sans Serif, Regular, 14

Caption Assignment 13 Developed by- SSMV , Date 19-10-2012

BorderStyle 1-fixed Single

Label 1 Name Lbl1

Caption Input 5 items in array and search any store items


CommandButton1 Name Cmdinput

Caption Input in array

CommandButton2 Name Cmdsearch

Caption Search

Code Window

Dim item(5) As String ' Diclaration as static array


____________________________________________
Private Sub cmdinput_Click()
For i = 1 To 5
item(i) = InputBox("Enter any name ", "Input Array Item ")
Print item(i)
Next i
End Sub
_________________________________________________________
Private Sub cmdsearch_Click()
Dim sname As String
sname = InputBox("Enter name for search ", "Search name ")
For i = 1 To 5
If sname = item(i) Then
found = 1
Exit For
Else
found = 0
End If
Next i
If found = 1 Then
MsgBox ( "Found " & " in the " & i & " position." )
Else
MsgBox ("Not Found .")
End If
End Sub

Output
Assignment 14 : WAP to sort a dynamic array of
(a)n numbers
(b)n strings (Input array size at run time)

Form Design
Form & Object Properties

Control Properties Setting

Form Name Assignment14

Font MS Sans Serif, Regular, 14

Caption Assignment 14 Developed by- SSMV , Date 19-10-2012

BorderStyle 1-fixed Single

Label 1 Name Lbl1

Caption Input items in dynamic array and sort stored items in array and
search any store item .

CommandButton1 Name CmdNA

Caption Numeric

CommandButton2 Name CmdSA

Caption String

Code Window

Private Sub cmdNA_Click()


assignment14.Cls
Dim item() As Integer
n = InputBox("Enter size of array", "Input size", 5)
ReDim item(n) As Integer
For i = 1 To n
item(i) = InputBox("Enter numeric array items", "Input ", 1)
Print item(i)
Next i
Print "----Sorting Array----"
For i = 1 To n ‘ Sorting array items(Using bubble sort method)
For j = i + 1 To n
If item(i) > item(j) Then
temp = item(i)
item(i) = item(j)
item(j) = temp
End If
Next j
Print item(i)
Next i
End Sub
___________________________________________________________
Private Sub cmdSA_Click()
assignment14.Cls
Dim item() As String
n = InputBox("Enter size of array", "Input size", 5)
ReDim item(n) As String
For i = 1 To n
item(i) = InputBox("Enter string array items", "Input ")
Print item(i)
Next i
Print "----Sorting Array----"
For i = 1 To n ‘ Sorting array items(Using bubble sort method)
For j = i + 1 To n
If item(i) > item(j) Then
temp = item(i)
item(i) = item(j)
item(j) = temp
End If
Next j
Print item(i)
Next i
End Sub

Output
Assignment 15 : WAP to take input of two
matrices and perform
their addition, subtraction
and multiplication using
menu editor.

Form Design
Form & Object Properties

Control Properties Setting

Form Name Assignment15

Font MS Sans Serif, Regular, 14

Caption Assignment 15 Developed by- SSMV , Date 26-10-2012

BorderStyle 1-fixed Single

Main Menu Name MM

Caption Matrix Manipulation

Sub Menu Name madd

Caption Addition

Sub Menu Name msub

Caption Subtraction

Sub Menu Name mmulti

Caption Multiplication

Label Name Lblresult

Caption Result

Allignment 2-Centre
Label (for Show the Name C
result of matrix create
9 control array of label Caption
name C with index 0 to Appearance 0-Flat
8)
Index 0 to 8

Textbox ( For Matrix A Name a


create 9 control array
of Text with index 0 to Text
8) Border Style 0-None

Index 0 to 8

Textbox ( For Matrix B Name b


create 9 control array
of Text with index 0 to Text
8) Border Style 0-None

Index 0 to 8

Code Window

Private Sub madd_Click()


lblresult.Caption = "Addition"
For i = 0 To 8
c(i).Caption = Val(a(i)) + Val(b(i))
Next i
End Sub
____________________________________________________________
Private Sub msub_Click()
lblresult.Caption = "Subtraction"
For i = 0 To 8
c(i).Caption = Val(a(i)) - Val(b(i))
Next i
End Sub
______________________________________________________________
Private Sub mmulti_Click()
lblresult.Caption = "Multiplication"

' Multiplication for first row


i=0
For j = 0 To 2
c(j).Caption = (Val(a(i)) * Val(b(j))) + (Val(a(i + 1)) * Val(b(j + 3))) + (Val(a(i + 2)) * Val(b(j + 6)))
Next j

' Multiplication for second row


i=3
k=3
For j = 0 To 2
c(k).Caption = (Val(a(i)) * Val(b(j))) + (Val(a(i + 1)) * Val(b(j + 3))) + (Val(a(i + 2)) * Val(b(j + 6)))
k=k+1
Next j

' Multiplication for third row


i=6
k=6
For j = 0 To 2
c(k).Caption = (Val(a(i)) * Val(b(j))) + (Val(a(i + 1)) * Val(b(j + 3))) + (Val(a(i + 2)) * Val(b(j + 6)))
k=k+1
Next j

End Sub

Output
Assignment 17 : WAP to illustrate call by value and call by reference ( to swap to values)

Form Design

Form & Object Properties

Control Properties Setting

Form Name Assignment17

Font MS Sans Serif, Regular, 14

Caption Assignment 17 Developed by- SSMV , Date 26-10-2012

BorderStyle 1-fixed Single

TextBox 1 Name Txtno1

text

TextBox 2 Name Lbl1

text First Number

Label 1 Name Lbl2

Caption Second Number

Label 2 Name Lblsno1

Caption

Label 3 Name Lblsno1

Caption

Appearance 0-Flat

Label 4 Name Lblsno2


Caption

Appearance 0-Flat

Label 5 Name Lblmessage

Caption

Appearance 0-Flat

CommandButton 1 Name cmdbyval

Caption Swap Number (By Value )

CommandButton 2 Name cmdbyref

Caption Swap Number (By Refrence )

Code Window
‘ General Declaration
Sub swapnobyref(ByRef no1 As Integer, ByRef no2 As Integer)
Dim tmpno As Integer
tmpno = no1
no1 = no2
no2 = tmpno
End Sub
______________________________________________________________
‘ General Declaration
Sub swapnobyval(ByVal no1 As Integer, ByVal no2 As Integer)
Dim tmpno As Integer
tmpno = no1
no1 = no2
no2 = tmpno
End Sub
_______________________________________________________
Private Sub cmdbyref_Click()
Dim n1 As Integer
Dim n2 As Integer
n1 = Val(Txtno1.Text)
n2 = Val(Txtno2.Text)
Call swapnobyref(n1, n2)
Lblsno1.Caption = n1
lblsno2.Caption = n2
lblmessage.Caption = "Swapped By Refrence"
End Sub
_________________________________________________________
Private Sub cmdbyval_Click()
Dim n1 As Integer
Dim n2 As Integer
n1 = Val(Txtno1.Text)
n2 = Val(Txtno2.Text)
Call swapnobyval(n1, n2)
Lblsno1.Caption = n1
lblsno2.Caption = n2
lblmessage.Caption = "Swapped By Value"
End Sub

Output

Assignment 18 : Write a program to calculate


factorial of a number using user defined function.

Form Design

Form & Object Properties

Control Properties Setting

Form Name Assignment18

Font MS Sans Serif, Regular, 14


Caption Assignment 18 Developed by- SSMV , Date 02-11-2012

BorderStyle 1-fixed Single

TextBox Name Txtno

text

Label 1 Name Lbl1

Caption Enter number for factorial

Label 2 Name Lbl2

Caption Factorial value

Label 3 Name Lblno

Caption

Appearance 0-Flat

CommandButton Name cmdfact

Caption Generate Factorial

Code Window
‘ General Declaration
Private Function factorial(no As Integer) As Integer
fact = 1
For n = 1 To no
fact = fact * n
Next n
factorial = fact 'function return value
End Function
______________________________________________________________
Private Sub cmdfact_Click()
Dim x As Integer
x = Val(txtno.Text)
lblno.Caption = factorial(x)
End Sub

Output
Assignment 19 : Take input of a word and WAP to check whether it is a palindrome or not. (Without using
structure fun)

Form Design
Form & Object Properties

Control Properties Setting

Form Name Assignment19

Font MS Sans Serif, Regular, 14

Caption Assignment 19 Developed by- SSMV , Date 02-11-2012

BorderStyle 1-fixed Single

TextBox Name Txtstring

text

Label 1 Name Lbl1

Caption Enter string for test palindrome

CommandButton Name cmdpalindrome

Caption Check Palindrome

Code Window

Private Sub cmdpalindrome_Click()


Dim str() As String
Dim x As Integer
x = Len(txtstring.Text)
ReDim str(x) As String

For i = 1 To x
str(i) = Mid(txtstring.Text, i, 1)
Next i

test = True
For j = 1 To UBound(str) / 2
If str(j) <> str((UBound(str) - j) + 1) Then
test = False
End If
Next j

If test = True Then


MsgBox "Your enter string is a palindrome"
Else
MsgBox "It is NOT a palindrome"
End If

End Sub

Output
Assignment 20 : WAP to find smallest among given three numbers using user defined procedures.

Form Design

Form & Object Properties

Control Properties Setting

Form Name Assignment20

Font MS Sans Serif, Regular, 14

Caption Assignment 20 Developed by- SSMV , Date 02-11-2012

BorderStyle 1-fixed Single

TextBox Name Txtno1

text

TextBox Name Txtno2

text

TextBox Name Txtno3


text

CommandButton Name cmdsmall

Caption Find Smallest

Code Window
‘ General Declaration
Private Sub smallest(a%, b%, c%)
Dim small As Integer
If (a < b) And (a < c) Then
MsgBox ("Smallest Number is " & a)
ElseIf (b < a) And (b < c) Then
MsgBox ("Smallest Number is " & b)
Else
MsgBox ("Smallest Number is " & c)
End If
End Sub
______________________________________________
Private Sub cmdsmall_Click()
Dim x As Integer
Dim y As Integer
Dim z As Integer

x = Val(txtno1.Text)
y = Val(txtno2.Text)
z = Val(txtno3.Text)

Call smallest(x, y, z)
End Sub

Output
Assignment 21 : WAP to generate, print and find sum of first n elements of fibonacci series using recursion.

Form Design

Form & Object Properties

Control Properties Setting

Form Name Assignment21

Font MS Sans Serif, Regular, 14


Caption Assignment 21 Developed by- SSMV , Date 09-11-2012

BorderStyle 1-fixed Single

TextBox Name Txtno

text 2

Label Name Lblsum

Appearance 0-Flat

Caption

CommandButton Name cmdsmall

Caption Find Smallest

Code Window

Dim x, y As Integer ‘ General Declaration


__________________________________________________
Private Function fibo(ByVal n%) As Integer ‘ Function Declaration
If n = 2 Then
fibo = 1
x=0
y=1
Print 0
Print 1
Else
fibo = fibo(n - 1)
c=x+y
x=y
y=c
Print c
Sum = Sum + c
fibo = Sum + fibo
End If
End Function
______________________________________________________
Private Sub cmdfibo_Click()
Dim fno As Integer
assignment21.Cls
fno = Val(txtno.Text)
lblsum.Caption = fibo(fno)
End Sub

Output
Assignment 22 : WAP to perform read write operations in a sequential file.

Form Design
Form & Object Properties

Control Properties Setting

Form Name Assignment22

Font MS Sans Serif, Regular, 14

Caption Assignment 22 Developed by- SSMV , Date 09-11-2012

BorderStyle 1-fixed Single

Label 1 Name Lbl1

Caption Name

Label 2 Name Lbl2

Caption Mobile Number

TextBox 1 Name Txtname

Text

TextBox 2 Name Txtmobno

Text

TextBox 3 Name Txtread

Text

Multiline true

Scrollbars 3 - Both

CommandButton1 Name Cmdwrite

Caption Write in file

CommandButton2 Name Cmdappend

Caption Append in file

CommandButton3 Name Cmdread

Caption Read from file


Code Window

Dim stname, stmobno As String ‘ General Declaration


_________________________________________________
Private Sub cmdwrite_Click()
stname = txtname.Text
stmobno = txtmobno.Text
If stname = "" Or stmobno = Null Then
MsgBox ("Empty data not store in file.Please enter in both field.")
Else
Open "c:\tmp.txt" For Output As #1
Print #1, stname, stmobno
Close #1
txtname.Text = ""
txtmobno.Text = ""
End If
End Sub
____________________________________________________________
Private Sub cmdappend_Click()
stname = txtname.Text
stmobno = txtmobno.Text
If stname = "" Or stmobno = Null Then
MsgBox ("Empty data not store in file.Please enter in both field.")
Else
Open "c:\tmp.txt" For Append As #1
Print #1, stname, stmobno
Close #1
txtname.Text = ""
txtmobno.Text = ""
End If
End Sub
__________________________________________________________
Private Sub Cmdread_Click()
Cls
Open "c:\tmp.txt" For Input As #1
Do
Input #1, stname, stmobno
txtread.Text = txtread.Text & stname & Chr(13) & Chr(10)
txtread.Text = txtread.Text & stmobno & Chr(13) & Chr(10)
Loop Until EOF(1)
Close #1
End Sub
Output
Assignment 23 : Create a user defined data type having fields name (as string of length 20 bytes), Rollno (as
integer), class (as string of 10 bytes). WAP to create a random access file to store above data
and perform following operations in this file.

Form Design

Form & Object Properties

Control Properties Setting

Form Name Assignment23

Font MS Sans Serif, Regular, 14

Caption Assignment 23 Developed by- SSMV , Date 09-11-2012

BorderStyle 1-fixed Single

Label 1 Name Lbl1

Caption Name

Label 2 Name Lbl2

Caption Roll Number


Label 3 Name Lbl3

Caption Class

TextBox 1 Name Txtname

Text

TextBox 2 Name Txtroll

Text

TextBox 3 Name Txtclass

Text

TextBox 3 Name Txtread

Text

Multiline true

Scrollbars 3 - Both

CommandButton 1 Name Cmdwrite

Caption Write in file

CommandButton 2 Name Cmdread

Caption Read from file

CommandButton 3 Name Cmddelete

Caption Delete Record

CommandButton 4 Name Cmdlist

Caption List Select Record

CommandButton 5 Name Cmdclose

Caption Close

Module Code
Note- Add a module from project menu and type the code which show in diagram and save it name with
student1.bas

Form Code Window


‘ General Declaration
Dim st As student
Dim no As Integer
__________________________________________________________
Private Sub cmdclose_Click()
Close #1
End
End Sub
__________________________________________________________
Private Sub cmddelete_Click()
delno = InputBox("Input record number for delete ")
st.stname = " "
st.stRollno = 0
st.stclass = " "
Put #1, delno, st
End Sub
___________________________________________________________
Private Sub cmdlist_Click()
search = InputBox("Input record number for list")
txtread.Text = ""
Get #1, search, st
txtread.Text = txtread.Text & Val(search) & ". " & st.stname & st.stRollno & " " & st.stclass & Chr(13) & Chr(10)
End Sub
____________________________________________________________
Private Sub cmdread_Click()
txtread.Text = ""
For n = 1 To (no - 1)
Get #1, n, st
txtread.Text = txtread.Text & Val(n) & ". " & st.stname & st.stRollno & " " & st.stclass & Chr(13) & Chr(10)
Next n
End Sub
Private Sub cmdwrite_Click()
st.stname = txtname.Text
st.stRollno = Val(txtroll.Text)
st.stclass = txtclass.Text
If txtname.Text = " " Or txtroll.Text = "" Or txtclass.Text = " " Then
MsgBox ("Some field are empty, Please fill the data")
Else
Put #1, no, st
no = no + 1
txtname.Text = ""
txtroll.Text = ""
txtclass.Text = ""
End If
End Sub
____________________________________________________________
Private Sub Form_Load()
no = 1
Open "c:\rtmp.txt" For Random As #1 Len = Len(st)
End Sub

Output
Assignment 24 : WAP to display records of a table using DAO & bound control code for buttons to move at first
record, next record, previous record, last record in the table.

Form Design

Form & Object Properties

Control Properties Setting

Form Name Assignment24

Font MS Sans Serif, Regular, 14

Caption Assignment 24 Developed by- SSMV , Date 23-11-2012

BorderStyle 1-fixed Single

Label 1 Name Lbl1

Caption Author ID

Label 2 Name Lbl2

Caption Author Name

Label 3 Name Lbl3

Caption Author Date of Birth

TextBox1 Name txtid


Text

DataField Au_ID

DataSource Data1

TextBox2 Name txtname

Text

DataField Author

DataSource Data1

TextBox3 Name txtdob

Text

DataField Year Born

DataSource Data1

Data Name Data1

Caption Data1

Connect Access

DatabaseName C:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB

RecordSource Author

Visible False

ReadOnly False

Recordset Type 1 . Dynaset

CommandButton 1 Name Cmdfirst

Caption First

CommandButton 2 Name Cmdnext

Caption next

CommandButton 3 Name Cmdprevious

Caption Previous

CommandButton 4 Name Cmdlast

Caption last
Code Window

Private Sub cmdfirst_Click()


Data1.Recordset.MoveFirst
End Sub
_____________________________
Private Sub cmdlast_Click()
Data1.Recordset.MoveLast
End Sub
_______________________________
Private Sub cmdnext_Click()
If Data1.Recordset.EOF = True Then
MsgBox ("There is no any record in next.")
Data1.Recordset.MoveLast
Else
Data1.Recordset.MoveNext
End If
End Sub
________________________________________
Private Sub cmdprevious_Click()
If Data1.Recordset.BOF = True Then
MsgBox ("There is no any record in previous.")
Data1.Recordset.MoveFirst
Else
Data1.Recordset.MovePrevious
End If
End Sub

Output

Assignment 25 : Create a table


using visual data manager and
write a program using RDO &
advanced
bound control to add, delete, edit
& navigate records.
Form Design
Form & Object Properties

Control Properties Setting

Form Name Assignment25

Font MS Sans Serif, Regular, 14

Caption Assignment 25 Developed by- SSMV , Date 23-11-2012

BorderStyle 1-fixed Single

Label 1 Name Lbl1

Caption Author ID

Label 2 Name Lbl2

Caption Author Name

Label 3 Name Lbl3

Caption Author Date of Birth

TextBox1 Name txtid

Text

DataField Au_ID

DataSource MSRDC1

TextBox2 Name txtname

Text

DataField Author

DataSource MSRDC1

TextBox3 Name txtdob


Text

DataField Year Born

DataSource MSRDC1

MSRDC Name MSRDC1

Caption MSRDC1

DataSourceName BCA

SQL select * from authors

Visible False

ReadOnly False

CommandButton 1 Name Cmdfirst

Caption First

CommandButton 2 Name Cmdnext

Caption next

CommandButton 3 Name Cmdprevious

Caption Previous

CommandButton 4 Name Cmdlast

Caption last

CommandButton 5 Name Cmdadd

Caption ADD

CommandButton 6 Name Cmddelete

Caption DELETE

CommandButton 7 Name Cmdedit

Caption EDIT

CommandButton 8 Name Cmdexit

Caption EXIT

Note – In this program First we use visual data manager and create new bca1.mdb file in path c:\ and import the
table C:\Program Files\Microsoft Visual Studio\VB98\BIBLIO.MDB then create ODBC system DSN using control
panel administrative tools name BCA with select data C:\bca1.mdb
Code Window

Private Sub cmddelete_Click()


Dim ans As String
ans = MsgBox("Are you sure want to delete ? ", 1)
If ans = 1 Then
MSRDC1.Resultset.Delete
MSRDC1.Refresh
End If
End Sub
______________________________________________________
Private Sub cmdedit_Click()
MSRDC1.Resultset.Edit
MSRDC1.Refresh
End Sub
------------------------------------------------------------------------------------------
Private Sub cmdexit_Click()
End
End Sub
Private Sub cmdadd_Click()
MSRDC1.Resultset.Addnew
End Sub
-------------------------------------------------------------------------------------------
Private Sub Cmdfirst_Click()
MSRDC1.Resultset.MoveFirst
End Sub
Private Sub Cmdlast_Click()
MSRDC1.Resultset.MoveLast
End Sub
--------------------------------------------------------------------------------------------
Private Sub Cmdprevious_Click()
If MSRDC1.Resultset.BOF = True Then
MsgBox ("There is no any record in previous.")
MSRDC1.Resultset.MoveFirst
Else
MSRDC1.Resultset.MovePrevious
End If
End Sub
--------------------------------------------------------------------------------------------------
Private Sub Cmdnext_Click()
If MSRDC1.Resultset.EOF = True Then
MsgBox ("There is no any record in next.")
MSRDC1.Resultset.MoveLast
Else
MSRDC1.Resultset.MoveNext
End If
End Sub

Output
Assignment 26 : WAP to access a database using ADO & display a key column in the combo box or list box
when an item is selected in it, its corresponding records is shown in MSH flex grid.

Form Design
Note : For this program first add new control Microsoft ADO Data Control 6.0 (OLEDB) and Microsoft Hierarchical
FlexGried Control 6.0(OLEDB) from add component and design it on form. Create BCAI, BCAII,BCAIII table in
STUDENT.MDB file using Microsoft Access. After create system DSN name STUDENT and select STUDENT.MDB
file using ODBC in control panel administrative tools .

Database design

Form & Object Properties

Control Properties Setting

Form Name Assignment26

Font MS Sans Serif, Regular, 14

Caption Assignment 26 Developed by- SSMV , Date 30-11-2012

BorderStyle 1-fixed Single

Label 1 Name Lbl1

Caption Select Class Name

ADODC Name Adodc1

Caption Adodc

Visible False

Recordsource

ConnectingString
ComboBox Name cmbclass

Text

MSHFlesGrid Name MSHFlesGrid

AllowUserResizing 3. flexresizeboth

FixedCols 0

FixedRows 1

Datamember

Datasource

Code Window

‘ General Declaration
Dim adoCon As ADODB.Connection
Dim adoRset As ADODB.Recordset
________________________________________
Private Sub cmbclass_Click()
If (cmbclass.Text = "BCA I") Then
Set adoCon = New ADODB.Connection
adoCon.ConnectionTimeout = 30
adoCon.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=STUDENT"
Set adoRset = New ADODB.Recordset
adoRset.Open " BCAI ", adoCon, , , adCmdTable
Set MSHFlesGrid.DataSource = adoRset
End If

If (cmbclass.Text = "BCA II") Then


Set adoCon = New ADODB.Connection
adoCon.ConnectionTimeout = 30
adoCon.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=STUDENT"
Set adoRset = New ADODB.Recordset
adoRset.Open " BCAII ", adoCon, , , adCmdTable
Set MSHFlesGrid.DataSource = adoRset
End If

If (cmbclass.Text = "BCA III") Then


Set adoCon = New ADODB.Connection
adoCon.ConnectionTimeout = 30
adoCon.Open "Provider=MSDASQL.1;Persist Security Info=False;Data Source=STUDENT"
Set adoRset = New ADODB.Recordset
adoRset.Open " BCAIII ", adoCon, , , adCmdTable
Set MSHFlesGrid.DataSource = adoRset
End If
End Sub
__________________________________________________
Private Sub Form_Load()
cmbclass.AddItem "BCA I"
cmbclass.AddItem "BCA II"
cmbclass.AddItem "BCA III"
End Sub

Output

Assignment 27 . Using Data Environment create a program to display records of any table..
Form Design

Note : For this program we need Data Environment if it is not available in project menu ,click on project menu
components then click on the Designers tab and select Data Environment.

Database design

For this program we need system DSN name STUDENT using database STUDENT.MDB
Environment Design
Form & Object Properties

Control Properties Setting


Form Name Assignment27

Font MS Sans Serif, Regular, 14

Caption Assignment 27 Developed by- SSMV , Date 01-12-2012

BorderStyle 1-fixed Single

CommandButton Name Lbl1

Caption First

Name cmdfirst

Caption Next

Name cmdprevious

Caption Previous

Name cmdlast

Caption Last

Name cmdnew

Caption Add New Record

Name cmddelete

Caption Delete record

DECommand Name Command1

ConnectionName Connection1

CursorType 2-adOpenDynamic

LockType 4-adLockBatchOptimistic

Code Window

Private Sub cmddelete_Click()


ans = MsgBox(" Are you sure for delete ? ", vbOKCancel)
If ans = 1 Then
DataEnvironment1.rsCommand1.Delete
End If
End Sub
-------------------------------------------------------------------------------
Private Sub cmdfirst_Click()
DataEnvironment1.rsCommand1.MoveFirst
End Sub
-------------------------------------------------------------------------------
Private Sub cmdlast_Click()
DataEnvironment1.rsCommand1.MoveLast
End Sub
-------------------------------------------------------------------------------
Private Sub cmdnew_Click()
DataEnvironment1.rsCommand1.AddNew
End Sub
-------------------------------------------------------------------------------
Private Sub cmdnext_Click()
If DataEnvironment1.rsCommand1.EOF = True Then
MsgBox (" No more recods !. ")
DataEnvironment1.rsCommand1.MoveLast
Else
DataEnvironment1.rsCommand1.MoveNext
End If

End Sub
-------------------------------------------------------------------------------
Private Sub cmdprevious_Click()
If DataEnvironment1.rsCommand1.BOF = True Then
MsgBox (" No more recods !. ")
DataEnvironment1.rsCommand1.MoveFirst
Else
DataEnvironment1.rsCommand1.MovePrevious
End If
End Sub

Output
Assignment 28. WAP to generate marksheet of students in a class through data report.

Form & Object Properties

Control Properties Setting

Form Name Assignment 28

Font MS Sans Serif, Regular, 14

Caption Assignment 28 Developed by- SSMV , Date 07-12-2012

Caption

Text 1 Name Txtstname


DataField Stname

Datamember Command1

Datasource Dataenvironment1

Text 2 Name Txtrollno

DataField Rollno

Datamember Command1

Datasource Dataenvironment1

Text 3 Name Txtmarks1

DataField Marks1

Datamember Command1

Datasource Dataenvironment1

Text 4 Name Txtmarks2

DataField Marks2

Datamember Command1

Datasource Dataenvironment1

Text 5 Name Txtmarks3

DataField Marks3

Datamember Command1

Datasource Dataenvironment1

Text 6 Name Txtmarks4

DataField Marks4

Datamember Command1

Datasource Dataenvironment1

Text 7 Name Txtmarks5

DataField Marks5

Datamember Command1

Datasource Dataenvironment1
Text 8 Name Txtmarks

DataField Total

Datamember Command1

Datasource Dataenvironment1

Text 9 Name Txtresult

DataField Result

Datamember Command1

Datasource Dataenvironment1

Text 10 Name Txtpercent

DataField Percent

Datamember Command1

Datasource Dataenvironment1

CommandButton1 Name cmdfirst

Caption First

CommandButton2 Name cmdnext

Caption Next

CommandButton3 Name cmdprevious

Caption Previous

CommandButton4 Name cmdlast

Caption Last

CommandButton5 Name cmdadd

Caption Add

CommandButton6 Name cmddelete

Caption Delete

CommandButton7 Name cmdshow

Caption Show Result

CommandButton8 Name cmdclose


Caption Close

Report Design

Report property

Control Properties Setting

DataReport Name DataReport1

DataSource Command1

Datamember Dataenvironment1
Database design

Note : Create system DSN Name BCAMARKS and select student.mdb MS-Access file. Design Dataenvironment1 add
command1 using BCAMARKS and student.mdb file then select table marks. Drag and drop command1 on the
datareport1 form and set according to given in datareport1.

Code Window

Private Sub cmdadd_Click()


DataEnvironment1.rsCommand1.AddNew
TxtPercent.Text = 0
Txtresult.Text = ""
End Sub

Private Sub cmdclose_Click()


End
End Sub

Private Sub cmddelete_Click()


ans = MsgBox(" Are you sure for delete ? ", vbOKCancel)
If ans = 1 Then
DataEnvironment1.rsCommand1.Delete
End If
End Sub

Private Sub cmdfirst_Click()


DataEnvironment1.rsCommand1.MoveFirst
txtmarks.Text = Val(txtmarks1.Text) + Val(txtmarks2.Text) + Val(txtmarks3.Text) + Val(txtmarks4.Text) +
Val(txtmarks5.Text)
TxtPercent.Text = Val(txtmarks.Text) / 4
If Val(TxtPercent.Text) >= 40 Then
Txtresult.Text = "Pass"
Else
Txtresult.Text = "Fail"
End If
End Sub

Private Sub cmdlast_Click()


DataEnvironment1.rsCommand1.MoveLast
txtmarks.Text = Val(txtmarks1.Text) + Val(txtmarks2.Text) + Val(txtmarks3.Text) + Val(txtmarks4.Text) +
Val(txtmarks5.Text)
TxtPercent.Text = Val(txtmarks.Text) / 4
If Val(TxtPercent.Text) >= 40 Then
Txtresult.Text = "Pass"
Else
Txtresult.Text = "Fail"
End If
End Sub

Private Sub cmdnext_Click()


If DataEnvironment1.rsCommand1.EOF = True Then
MsgBox (" No more recods !. ")
DataEnvironment1.rsCommand1.MoveLast
Else
DataEnvironment1.rsCommand1.MoveNext
End If
txtmarks.Text = Val(txtmarks1.Text) + Val(txtmarks2.Text) + Val(txtmarks3.Text) + Val(txtmarks4.Text) +
Val(txtmarks5.Text)
TxtPercent.Text = Val(txtmarks.Text) / 4
If Val(TxtPercent.Text) >= 40 Then
Txtresult.Text = "Pass"
Else
Txtresult.Text = "Fail"
End If
End Sub

Private Sub cmdprevious_Click()


If DataEnvironment1.rsCommand1.BOF = True Then
MsgBox (" No more recods !. ")
DataEnvironment1.rsCommand1.MoveFirst
Else
DataEnvironment1.rsCommand1.MovePrevious
End If
txtmarks.Text = Val(txtmarks1.Text) + Val(txtmarks2.Text) + Val(txtmarks3.Text) + Val(txtmarks4.Text) +
Val(txtmarks5.Text)
TxtPercent.Text = Val(txtmarks.Text) / 4
If Val(TxtPercent.Text) >= 40 Then
Txtresult.Text = "Pass"
Else
Txtresult.Text = "Fail"
End If
End Sub

Private Sub cmdshow_Click()


DataReport1.Show
End Sub

Private Sub Form_Load()


txtmarks.Text = Val(txtmarks1.Text) + Val(txtmarks2.Text) + Val(txtmarks3.Text) + Val(txtmarks4.Text) +
Val(txtmarks5.Text)
TxtPercent.Text = Val(txtmarks.Text) / 4
If Val(TxtPercent.Text) >= 40 Then
Txtresult.Text = "Pass"
Else
Txtresult.Text = "Fail"
End If
End Sub

Private Sub txtmarks1_Change()


txtmarks.Text = Val(txtmarks1.Text) + Val(txtmarks2.Text) + Val(txtmarks3.Text) + Val(txtmarks4.Text) +
Val(txtmarks5.Text)
End Sub

Private Sub txtmarks2_Change()


txtmarks.Text = Val(txtmarks1.Text) + Val(txtmarks2.Text) + Val(txtmarks3.Text) + Val(txtmarks4.Text) +
Val(txtmarks5.Text)
End Sub

Private Sub txtmarks3_Change()


txtmarks.Text = Val(txtmarks1.Text) + Val(txtmarks2.Text) + Val(txtmarks3.Text) + Val(txtmarks4.Text) +
Val(txtmarks5.Text)
End Sub

Private Sub txtmarks4_Change()


txtmarks.Text = Val(txtmarks1.Text) + Val(txtmarks2.Text) + Val(txtmarks3.Text) + Val(txtmarks4.Text) +
Val(txtmarks5.Text)
End Sub

Private Sub txtmarks5_Change()


txtmarks.Text = Val(txtmarks1.Text) + Val(txtmarks2.Text) + Val(txtmarks3.Text) + Val(txtmarks4.Text) +
Val(txtmarks5.Text)
TxtPercent.Text = Val(txtmarks.Text) / 4
If Val(TxtPercent.Text) >= 40 Then
Txtresult.Text = "Pass"
Else
Txtresult.Text = "Fail"
End If
End Sub

Output
Assignment 29. WAP to illustrate various key board and mouse events.
Form & Object Properties

Control Properties Setting

Form Name Assignment29

Font MS Sans Serif, Regular, 14

Caption Assignment 29 Developed by- SSMV , Date 08-12-2012

BorderStyle 1-fixed Single

Label 1 Name Label1

Caption

Appearance 1-Fixed Single

Backcolor &H80000003&

Label 2 Name Label2

Caption

Appearance 1-Fixed Single

Label 3 Name Label3

Caption Follow mouse event on the image

Label 4 Name Label4

Caption Follow keyboard event on the image

TextBox Name Text1

Caption

Code Window

Private Sub Label1_Click()


Label2.Caption = "Mouse Click event"
End Sub
Private Sub Label1_DblClick()
Label2.Caption = "Mouse Double Click event"
End Sub

Private Sub Label1_DragOver(Source As Control, X As Single, Y As Single, State As Integer)


Label2.Caption = "Mouse Drag over event"
End Sub

Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)


Label2.Caption = "Mouse down event "
End Sub

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)


Label2.Caption = "Mouse move event"
End Sub

Private Sub Text1_Change()


Label2.Caption = "Keyboard change event"
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)


Label2.Caption = "Keyboard key down event"
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


Label2.Caption = "Keyboard key Press event"
End Sub

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)


Label2.Caption = "Keyboard key up event"
End Sub

Output

Assignment 30 . Using drive, directory and file list


box (it will show only .bmp files). Let the user select the
bmb files, which will appear in picture box as user click on any item in list box.
Form & Object Properties

Control Properties Setting

Form Name Assignment29

Font MS Sans Serif, Regular, 14

Caption Assignment 30 Developed by- SSMV , Date 14-12-2012

BorderStyle 1-fixed Single

Label Name Path

Caption

Appearance 1-Fixed Single

DriveListBox Name Drive1

DirListBox Name Dir1

FileListBox Name File1

Image Name Image1

Stretch True
Code Window

Private Sub Dir1_Change()


File1.Path = Dir1.Path
File1.FileName = "*.bmp"
End Sub
______________________________________________
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
______________________________________________
Private Sub File1_Click()
Dim file As String
If Right(File1.Path, 1) = "\" Then
file = File1.Path + File1.FileName
Else
file = File1.Path + "\" + File1.FileName
End If
Path.Caption = file
Image1.Picture = LoadPicture(file)
End Sub

Output
Assignment 31. Using toolbar design an interface for string manipulation. Toolbar should have tabs to (a) Find
length of string (b) No of blank spaces in sting (c) Reverse the string Also show current date &
time in status bar.

Note: First we add new component Microsoft Windows Common Control 6.0(SP6) in toolbar

Form & Object Properties

Control Properties Setting

Form Name Assignment31

Font MS Sans Serif, Regular, 14

Caption Assignment 30 Developed by- SSMV , Date 15-12-2012

Label 1 Name Label1

Caption Type any string

Label 2 Name Lbl1


Caption

Border Style 1 Fixed Single

Label 3 Name Lblans

Caption

Appearance 0 - Flat

TextBox Name Txtstring

Text

ImageList Name ImageList1

StatusBar Name Statusbar1

Toolbar Name Toolbar1

Image List Property

Path for Insert Picture

Toolbar Property
Statusbar Property

Code Window

‘General Declaration
Dim x As Integer
Dim str() As String

Private Sub Form_Load()


StatusBar1.Panels("p1").Text = Now
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)


Select Case Button.Key

Case "k1"
lbl1.Caption = "Length of string"
x = Val(Len(txtstring.Text))
lblans.Caption = x
Case "k2"
lbl1.Caption = "Blank Spaces"
y=0
ReDim str(x) As String

For i = 1 To x
str(i) = Mid(txtstring.Text, i, 1)
If str(i) = " " Then
y=y+1
End If
Next i

lblans.Caption = y

Case "k3"
lbl1.Caption = "Reverse String"
lblans.Caption = StrReverse(txtstring.Text)
End Select

End Sub

Output

You might also like