Escolar Documentos
Profissional Documentos
Cultura Documentos
Class: SYBCA C
Roll no: 292
______________________________________________________________________________
Create the following application in VB. The form should contain the following menu
Draw
Modify
Exit
Circle
Shrink
Expand
Erase
On selection of the menu option Circle, a circle should be drawn on the screen. The user
can Shrink, Expand or Erase the circle by selecting the menu option or by displaying a
popup menu after the right mouse button is clicked or pressed. The popup menu should
contain the option Shrink, Expand or Erase which should perform the same operation as
the menu option.
Code:
Private Sub circle_Click()
Shape1.Visible = True
End Sub
Private Sub erase_Click()
Shape1.Visible = False
End Sub
Private Sub exit_Click()
Unload Me
End Sub
Private Sub expand_Click()
Shape1.Height = Shape1.Height + 100
Shape1.Width = Shape1.Width + 100
End Sub
Private Sub shrink_Click()
Shape1.Height = Shape1.Height - 100
Shape1.Width = Shape1.Width - 100
End Sub
Output:
______________________________________________________________________________
Write a VB Program for Dental Payment Form. Calculate total on selected options from check
boxes.
Code:
Dim s As Integer
Private Sub Command1_Click()
s=0
If Check1.Value = 1 Then s = s + Label3.Caption
If Check2.Value = 1 Then s = s + Label4.Caption
If Check3.Value = 1 Then s = s + Label5.Caption
If Check4.Value = 1 Then s = s + Label6.Caption
If Check5.Value = 1 Then s = s + Label7.Caption
If Check6.Value = 1 Then s = s + Text2.Text
Text3 = s
End Sub
Output:
Output:
Output:
Output:
______________________________________________________________________________
Write a VB Program to accept the details of employee from user & store those details in to the
database. (Dont use Standard controls) Employee having fields emp_code, emp_name,
salary, dateofjoining.
Code:
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
Dim s As Double
Dim d As Date
s = Text3
d = Text4
con.Open
rs.Open "emp", con
rs.AddNew
rs.Fields(0) = Text1
rs.Fields(1) = Text2
rs.Fields(2) = s
rs.Fields(3) = d
rs.Update
rs.Close
con.Close
End Sub
Private Sub Command2_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
rs.LockType = adLockOptimistic
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents
and Settings\pract\My Documents\emp.mdb;Persist Security Info=False"
End Sub
Output:
Output:
Output:
Output:
Output:
Output:
Class: SYBCA C
Roll no: 292
______________________________________________________________________________
Write a VB program to search an employee record from the database according to the empcode
and display that record onto the form. (Use Input box).
Code:
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
Dim str As String
str = InputBox("Enter Emp No. to Search in the Database...")
con.Open
Set rs = New ADODB.Recordset
rs.Open "select * from Employee where eno='" & str & "'", con
If rs.EOF Then
MsgBox "Employee Not Found!"
Else
Text1 = rs.Fields(0)
Text2 = rs.Fields(1)
Text3 = rs.Fields(2)
Text4 = rs.Fields(3)
End If
rs.Close
con.Close
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents
and Settings\Administrator\My Documents\Database1_256.mdb;Persist Security Info=False"
End Sub
Output:
Code:
Private Sub Command1_Click()
Dim i As Integer
Dim j As Integer
i = InStr(Text4, "@")
j = InStr(Text4, ".")
If i <= 0 Or j <= 0 Then
MsgBox "@ or .is missing"
Text4.SetFocus
Else
MsgBox "Data validated..."
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Text1_Change()
If IsNumeric(Right(Text1, 1)) = True Then
Text1 = Left(Text1, Len(Text1) - 1)
MsgBox "No numbers allowed"
End If
End Sub
Output:
Output:
Output:
Class: SYBCA C
Roll no: 292
______________________________________________________________________________
Write a menu driven program in VB for reservation & cancellation of tickets for an airline. The
menu should also contain an option for displaying the reservation details. The
program should ask for the no. of tickets that the user wants to book and category
(Business class, First class & Economy) use a ListBox control .Display number of tickets
booked, Category & total amount. The reservation details should display no. of tickets
booked at any instant of time category-wise.
Code:
Private Sub add_Click()
Adodc1.Recordset.AddNew
End Sub
Private Sub can_Click()
Adodc1.Recordset.Delete
End Sub
Private Sub res_Click()
Adodc1.Recordset.Save
End Sub
Private Sub sb_Click()
Adodc2.Refresh
DataGrid1.Refresh
DataGrid1.Visible = True
End Sub
Output:
Output:
Output:
Output:
Output:
Output:
Output:
Output:
User will select color from option button and style from check boxes that should apply
to text in text boxes. When user press on Display button that image should be displayed
in the picture box.
Code:
Private Sub Check1_Click()
If Check1.Value = 1 Then
Text2.FontBold = True
Else
Text2.FontBold = False
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then
Text2.FontItalic = True
Else
Text2.FontItalic = False
End If
End Sub
Private Sub Check3_Click()
If Check3.Value = 1 Then
Text2.FontUnderline = True
Else
Text2.FontUnderline = False
End If
End Sub
Output:
______________________________________________________________________________
Write a VB program to load picture box at a runtime.
Code:
Private Sub Command1_Click()
Load Picture1(1)
Picture1(1).Picture = LoadPicture("C:\WINDOWS\Web\Wallpaper\Azul.jpg")
Picture1(1).Visible = True
End Sub
Output:
Output:
Output:
Output:
chart
Output:
Code:
Private Sub Command1_Click()
If veg.Value = True Then
If small.Value = True Then Text1 = 200
If medium.Value = True Then Text1 = 300
If large.Value = True Then Text1 = 400
Else
If small.Value = True Then Text1 = 300
If medium.Value = True Then Text1 = 400
If large.Value = True Then Text1 = 500
End If
End Sub
Output: