0% found this document useful (0 votes)
133 views17 pages

Visual Programming Lab Projects in VB

The document outlines 12 visual basic programming lab assignments, including designing a calculator, student information form, MDI application with formatting options, encryption/decryption program, vending machine application, alarm clock, database validation, airline reservation system, item management application, employee payroll application, ATM application, and interest calculation programs using DLLs. The assignments cover concepts like functions, user interfaces, MDI forms, formatting, encryption, arrays, databases, calculations, and validation. Students are instructed to complete the assignments using various VB controls and features.

Uploaded by

geraldine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views17 pages

Visual Programming Lab Projects in VB

The document outlines 12 visual basic programming lab assignments, including designing a calculator, student information form, MDI application with formatting options, encryption/decryption program, vending machine application, alarm clock, database validation, airline reservation system, item management application, employee payroll application, ATM application, and interest calculation programs using DLLs. The assignments cover concepts like functions, user interfaces, MDI forms, formatting, encryption, arrays, databases, calculations, and validation. Students are instructed to complete the assignments using various VB controls and features.

Uploaded by

geraldine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 17

BCA405P – VISUAL PROGRAMMING LAB Page 1 of 17

BCA405P – VISUAL PROGRAMMING LAB

Part A
1. Write a VB program to design a simple calculator to perform addition, subtraction,
multiplication and division (Use functions for the calculations).
2. Design a User Interface (UI) to accept the student details such as name, department, and
total marks. Validate the input data and calculate the percentage and division.
3. Design a VB application which has MDI and child forms. Create a Menu having the items
such as File(New,Open), Format(Font, regular, Bold, Italic ) and Exit in the MDI form. Also
create a text box and use a Common Dialog Box control for changing the font, forecolor and
back color of the text box.
4. VB Program to Encrypt and Decrypt a string. (Use Rnd() to generate the Encryption and
Decryption keys).
5. Create a vending machine application, that display images for four snacks, and
corresponding labels that indicate number for each snack. The GUI should contain a text
box in which the user specifies the number of the desired snack. When the dispense snack
button is clicked, it should display on a label the name of the snack dispensed. At end it
should print (display) the bill of the product.
6. Design a small Alarm Clock Application.
7. Write a VB program to validate the username and password from the database and
display the appropriate message. (use Data Control)
8. Write an application for Airline Reservation System, which allows the user to book ticket
on a particular date for a particular type of class. At the end, once the ticket is booked, it
should display a boarding pass indicating the person’s seat no., type of class and total fare.
Input validations should be done properly. You can use arrays or databases for storing the
information.

Part B
9. Design a VB application to accept the Item Details (ItemId, ItemName, MfdDate,
UnitOfMeasure, and RatePerUnit). ItemId should be a system generated id. The application
should allow the operations - Add, Modify, Delete, Update and Navigations of the items.
Use ADO Data controls and Grid Controls.
10. Design a VB application to record the Employee Details such as EmpId, EmpName,
Designation, and BasicPay. Calculate the DA, HRA, Deductions and Gross Salary. (Make
the necessary assumptions). Use Select=Case for decision making.
11. Design a mini ATM Application, which validates the user on the basis of its account no.,
and password. After validation customer is allowed to do many operations such as
withdrawal, mini statement, checking balance etc. Application should perform the concerned
operation and the account of the user should be updated accordingly.
12. VB program to calculate the Simple Interest and Compound Interest. Use DLLs for the
calculations.

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 2 of 17

1. Write a VB program to design a simple calculator to perform addition, subtraction,


multiplication and division (Use functions for the calculations).

Dim x As Double
Dim y As Double
Dim z As Double
Dim optr As String
Dim fun As Integer

Private Sub cmdans_Click()


fun = 1
Select Case optr
Case "+"
z=y+x
lblDisplay = Str(z)
Case "-"
z=y-x
lblDisplay = Str(z)
Case "*"
z=y*x
lblDisplay = Str(z)
Case "/"
z=y/x
lblDisplay = Str(z)
End Select
End Sub

Private Sub cmdclear_Click()


x=y=0
[Link] = ""
End Sub

Private Sub cmdno_Click(Index As Integer)


If fun = 1 Then
[Link] = ""
End If
[Link] = [Link] & cmdno(Index).Caption
x=y=0
x = Val([Link])
fun = 0
End Sub

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 3 of 17

Private Sub cmdoptr_Click(Index As Integer)


[Link] = ""
y=x
x=0
optr = cmdoptr(Index).Caption
End Sub

Private Sub Form_Load()


[Link] = "Simple Calculator"
End Sub

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 4 of 17

2. Design a User Interface (UI) to accept the student details such as name, department, and
total marks. Validate the input data and calculate the percentage and division.

Private Sub cmdcal_Click()


Dim total As Integer
Dim Per As Double

total = Val([Link])

If [Link] = "" Or [Link] = "" Or [Link] = "" Or total = 0 Then


MsgBox "All Fields are Mandatory", vbOKOnly, "Student Details"
[Link]
Exit Sub
End If

If total > 600 Then


MsgBox "Invalid Data", vbOKOnly, "Student Details"
[Link] = ""
[Link]
Exit Sub
End If

Per = (total / 600) * 100


Per = FormatNumber(Per, 2)

If Per >= 80 Then


MsgBox "Percentage: " & Per & "%" & Chr(13) & "Division: Distinction", vbOKOnly, "Student Details"
ElseIf Per >= 60 Then
MsgBox "Percentage: " & Per & "%" & Chr(13) & "Division: First Class", vbOKOnly, "Student Details"
ElseIf Per >= 40 Then
MsgBox "Percentage: " & Per & "%" & Chr(13) & "Division: Second Class", vbOKOnly, "Student Details"
ElseIf Per >= 35 Then
MsgBox "Percentage: " & Per & "%" & Chr(13) & "Division: Pass Class", vbOKOnly, "Student Details"
Else
MsgBox "Percentage: " & Per & "%" & Chr(13) & "Division: Fail", vbOKOnly, "Student Details"
End If
[Link] = ""
[Link] = ""
[Link] = ""
[Link]
End Sub

Private Sub Form_Load()


[Link] = ""

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 5 of 17

[Link] = ""
[Link] = ""
[Link] = 3900
[Link] = 2790
[Link] = "Student Details"
[Link] = 3
End Sub

Private Sub txtdname_KeyPress(KeyAscii As Integer)


If (KeyAscii >= vbKeyA And KeyAscii <= vbKeyZ) Then
Exit Sub
Else
KeyAscii = 0
End If
End Sub
Private Sub txtname_KeyPress(KeyAscii As Integer)
If (KeyAscii >= vbKeyA And KeyAscii <= vbKeyZ) Then
Exit Sub
Else
KeyAscii = 0
End If
End Sub
Private Sub txttmarks_KeyPress(KeyAscii As Integer)
If (KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Then
Exit Sub
Else
KeyAscii = 0
End If
End Sub

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 6 of 17

3. Design a VB application which has MDI and child forms. Create a Menu having the items
such as File(New,Open), Format(Font, regular, Bold, Italic ) and Exit in the MDI form. Also
create a text box and use a Common Dialog Box control for changing the font, forecolor and
back color of the text box.

Private Sub bckclr_Click()


[Link]
[Link] = [Link]
End Sub

Private Sub fclr_Click()


[Link]
[Link] = [Link]
End Sub

Private Sub fnt_Click()


[Link] = cdlCFBoth Or cdlCFEffects
[Link]
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
[Link] = [Link]
End Sub

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 7 of 17

4. VB Program to Encrypt and Decrypt a string.

Dim encryptval As String


Dim decryptval As String
Dim strlen As Integer
Dim i As Integer
Dim mychar As String

Private Sub cmdclear_Click()


[Link] = ""
[Link] = ""
[Link] = ""
[Link]
[Link] = True
[Link] = False
End Sub

Private Sub cmddecrp_Click()


Dim mynewstring As String
mystring = [Link]
mychar = ""
strlen = Len(mystring)
For i = 1 To strlen
mychar = Mid(mystring, i, 1)
Select Case Asc(mychar)
Case 192 To 217
mychar = Chr(Asc(mychar) - 127)
Case 218 To 243
mychar = Chr(Asc(mychar) - 121)
Case 244 To 253
mychar = Chr(Asc(mychar) - 196)
Case 32
mychar = Chr(32)
End Select
mynewstring = mynewstring + mychar
Next

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 8 of 17

decryptval = mynewstring
[Link] = decryptval
[Link] = False
[Link] = False
End Sub
Private Sub cmdencrp_Click()
Dim mynewstring As String
mystring = [Link]
mychar = ""
strlen = Len(mystring)
For i = 1 To strlen
mychar = Mid(mystring, i, 1)
Select Case Asc(mychar)
Case 65 To 90
mychar = Chr(Asc(mychar) + 127)
Case 97 To 122
mychar = Chr(Asc(mychar) + 121)
Case 48 To 57
mychar = Chr(Asc(mychar) + 196)
Case 32
mychar = Chr(32)
End Select
mynewstring = mynewstring + mychar
Next i
encryptval = mynewstring
[Link] = encryptval
[Link] = False
[Link] = True
End Sub

Private Sub Form_Load()


[Link] = "Encryption and Decryption"
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = True
[Link] = False
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)


If (KeyAscii >= 97 And KeyAscii <= 122) Or (KeyAscii >= vbKeyA And KeyAscii <= vbKeyZ) Or (KeyAscii
>= vbKey0 And KeyAscii <= vbKey9) Or KeyAscii = vbKeySpace Or KeyAscii = vbKeyBack Or KeyAscii =
46 Then
Exit Sub
Else
KeyAscii = 0
End If
End Sub

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 9 of 17

5. Create a vending machine application, that display images for four snacks, and
corresponding labels that indicate number for each snack. The GUI should contain a text
box in which the user specifies the number of the desired snack. When the dispense snack
button is clicked, it should display on a label the name of the snack dispensed. At end it
should print (display) the bill of the product.

Code for Form1


Dim g As Integer
Dim k As Integer
Dim m As Integer
Dim v As Integer

Private Sub cmddispence_Click()


[Link] = True
g = Val([Link])
k = Val([Link])
m = Val([Link])
v = Val([Link])

If (g <> 0) And [Link] = "" Then


[Link] = "snack1"

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 10 of 17

[Link] = g
[Link] = "55"
[Link] = 55 * g
End If

If (k <> 0) And [Link] <> "" Then


[Link] = "snack2"
[Link] = k
[Link] = "65"
[Link] = 65 * k
ElseIf (k <> 0) And [Link] = "" Then
[Link] = "snack2"
[Link] = k
[Link] = "65"
[Link] = 65 * k
End If

If (m <> 0) And [Link] = "" Then


[Link] = "snack3"
[Link] = m
[Link] = "75"
[Link] = 75 * m
ElseIf (m <> 0) And [Link] = "" Then
[Link] = "snack3"
[Link] = m
[Link] = "75"
[Link] = 75 * m
ElseIf (m <> 0) And [Link] = "" Then
[Link] = "snack3"
[Link] = m
[Link] = "75"
[Link] = 75 * m
End If

If (v <> 0) And [Link] = "" Then


[Link] = "snack4"
[Link] = v
[Link] = "85"
[Link] = 85 * v
ElseIf (v <> 0) And [Link] = "" Then
[Link] = "snack4"
[Link] = v
[Link] = "85"
[Link] = 85 * v
ElseIf (v <> 0) And [Link] = "" Then
[Link] = "snack4"
[Link] = v
[Link] = "85"
[Link] = 85 * v
ElseIf (v <> 0) And [Link] = "" Then
[Link] = "snack4"
[Link] = v
[Link] = "85"
[Link] = 85 * v

End If

[Link] = "Bill Amount: " & Val([Link]) +


Val([Link]) + Val([Link]) + Val([Link])

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 11 of 17

End Sub
Private Sub cmdprintbill_Click()
Unload Me
[Link]
End Sub
Private Sub Form_Load()
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = ""
[Link] = False
End Sub

Code for Form2


Private Sub cmdback_Click()
Unload Me
[Link]
End Sub

Private Sub Form_Load()


[Link] = "Date: " & Format(Date, "dd-mmm-yyyy")
End Sub

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 12 of 17

6. Design a small Alarm Clock Application.

Dim Atime As String


Private Sub cmdrsa_Click()
[Link] = ""
[Link] = False
Call cmdsa_Click
End Sub
Private Sub cmdsa_Click()
Atime = InputBox("Please enter your alarm time in the following format:- hh:mm:ss", "Set Alarm",
Time)
If Atime = "" Then
MsgBox "No Alarm Set!", vbCritical, "Error!"
Exit Sub
Else
[Link] = 1000
[Link] = "Next Alaram => " & Atime
[Link] = True
MsgBox ("Your alarm is set for: " & Atime), vbInformation, "Information"
End If
End Sub
Private Sub Form_Load()
[Link] = "Alaram Setting"
[Link] = ""
[Link] = False
End Sub
Private Sub Timer1_Timer()
[Link] = "Current Time=> " & Time
End Sub

Private Sub Timer2_Timer()


If Time = Atime Then
MsgBox "TRRRRRRRRRIIIIIIIIIIIIIINNNNNNNNN", vbOKOnly, "Alaram Ringing"
[Link] = ""
[Link] = False
[Link] = 0
End If
End Sub

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 13 of 17

7. Write a VB program to validate the username and password from the database and
display the appropriate message. (use Data Control)

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 14 of 17

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 15 of 17

Private Sub cmdlogin_Click()


If [Link] = "" And [Link] = "" Then
MsgBox "All fields are Mandatory", vbOKOnly, "Login"
Exit Sub
End If

If [Link] = "" And [Link] <> "" Then


MsgBox "User Name not found", vbOKOnly, "Login"
Exit Sub
End If

If [Link] <> "" And [Link] = "" Then


MsgBox "Password not found", vbOKOnly, "Login"
Exit Sub
End If

[Link]
[Link]
While Not [Link]
If [Link] = [Link](0) And [Link] = [Link](1)
Then
MsgBox "you have logged in Sucessfully", vbOKOnly, "Login"
[Link] = ""
[Link] = ""
Exit Sub
Else
[Link]
End If
Wend
MsgBox "Login Failed", vbOKOnly, "Login"
[Link] = ""
[Link] = ""

End Sub

Private Sub cmdstop_Click()


MsgBox " You are not Authorised to use this Software", vbOKOnly, "Login"
End
End Sub

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 16 of 17

8. Write an application for Airline Reservation System, which allows the user to book ticket
on a particular date for a particular type of class. At the end, once the ticket is booked, it
should display a boarding pass indicating the person’s seat no., type of class and total fare.
Input validations should be done properly. You can use arrays or databases for storing the
information.

[Link]
BCA405P – VISUAL PROGRAMMING LAB Page 17 of 17

9. Design a VB application to accept the Item Details (ItemId, ItemName, MfdDate,


UnitOfMeasure, and RatePerUnit). ItemId should be a system generated id. The application
should allow the operations - Add, Modify, Delete, Update and Navigations of the items.
Use ADO Data controls and Grid Controls.

10. Design a VB application to record the Employee Details such as EmpId, EmpName,
Designation, and BasicPay. Calculate the DA, HRA, Deductions and Gross Salary. (Make
the necessary assumptions). Use Select=Case for decision making.

11. Design a mini ATM Application, which validates the user on the basis of its account no.,
and password. After validation customer is allowed to do many operations such as
withdrawal, mini statement, checking balance etc. Application should perform the concerned
operation and the account of the user should be updated accordingly.

12. VB program to calculate the Simple Interest and Compound Interest. Use DLLs for the
calculations.

[Link]

You might also like