Você está na página 1de 75

Name: Aditya Jha

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:

Name: Aditya Jha


Class: SYBCA C
Roll no: 292

______________________________________________________________________________
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:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB Program to place three text boxes onto the form at run time. Enter different strings in
first and second textbox. On clicking to command button, concatenation of two strings
should be displayed in the third text box.
Code:
Private Sub Command1_Click()
Load Text1(1)
Text1(1).Visible = True
Text1(1).Top = Text1(0).Top + 1000
Text1(1).Height = Text1(0).Height
Load Text1(2)
Text1(2).Visible = True
Text1(2).Top = Text1(1).Top + 1000
Text1(2).Height = Text1(0).Height
End Sub
Private Sub Command2_Click()
Text1(2) = Text1(0) + Text1(1)
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Design an application in VB which has a Drivelistbox, Dirlistbox, Filelistbox control.
The form contains the following command buttons:
All drives: Display all drives in computer (including network drives)
All subdirectories: Display all subfolders of the currently selected directory.
All files : Display a popup menu which contains the following options:
a. All document files
b All bitmaps
c All files
On selection of option, display the specified type.
Code:
Private Sub abitmap_Click()
File1.Pattern = "*.bmp"
End Sub
Private Sub adocs_Click()
File1.Pattern = "*.docx"
End Sub
Private Sub afls_Click()
File1.Pattern = "*.*"
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub File1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As
Single)
If Button = 2 Then PopupMenu menu
End Sub
Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB Program to find transpose of given matrix.
Code:
Private Sub Command1_Click()
Dim arr(2, 1) As Integer
Dim r As Integer, c As Integer
Dim d As Integer
For r = 0 To 2
For c = 0 To 1
d = InputBox(" enter data : ")
arr(r, c) = d
Print arr(r, c);
Next
Print
Next
Print
Print "TRANSPOSE OF MATRIX IS"
Print
For r = 0 To 1
For c = 0 To 2
Print arr(c, r);
Next
Print
Next
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program to create a Stop Watch. It contains buttons Start, Stop, Pause and Reset. It
should display time in hours, minute, second, millisecond.
Code:
Private Sub Command1_Click()
If Timer1.Enabled = False Then
Timer1.Enabled = True
End If
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Command3_Click()
Timer1.Enabled = False
Label3.Caption = 0
Label2.Caption = 0
Label1.Caption = 0
End Sub
Private Sub Command4_Click()
Timer1.Enabled = False
Label3.Caption = 0
Label2.Caption = 0
Label1.Caption = 0
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Label3.Caption = Val(Label3.Caption) + Val(1)
If Label3.Caption = 60 Then
Label2.Caption = Val(Label2.Caption) + Val(1)
Label3.Caption = 0
ElseIf Label2.Caption = 60 Then
Label1.Caption = Val(Label1.Caption) + Val(1)
Label2.Caption = 0
ElseIf Label1.Caption = 60 Then
Label7.Caption = Val(Label7.Caption) + Val(1)
Label1.Caption = 0
End If
End Sub
Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Design an application that contains one Label and two combo boxes, one combo box contains
any text and second combo box contains color names. Write a VB Program to set caption
and background color to the label control from respective combo boxes.
Code:
Private Sub Combo1_Click()
Label1.Caption = Combo1.Text
End Sub
Private Sub Combo2_Click()
If Combo2.Text = "Red" Then Label1.BackColor = vbRed
If Combo2.Text = "Green" Then Label1.BackColor = vbGreen
If Combo2.Text = "Blue" Then Label1.BackColor = vbBlue
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C
Roll no: 292

______________________________________________________________________________
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:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB Program to accept a number from user and check whether it is palindrome
or not (Accept number using input box ) and display result using message box.
Code:
Private Sub Command1_Click()
Dim str As String
str = InputBox("enter no.")
If str = StrReverse(str) Then MsgBox ("yes palindrome") Else MsgBox ("not palindrome")
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program to accept the details of doctor having fields dno, dname, address, and
phone number. Display those details on to the grid.
Code:
Dim r As Integer
Private Sub Command1_Click()
For i = 0 To 3
ms1.Col = i
ms1.Row = r
ms1.Text = Text1(i)
Next '
r=r+1
End Sub
Private Sub Form_Load()
ms1.Row = 0
ms1.Col = 0
ms1.Text = "Dno."
ms1.Col = 1
ms1.Text = "Dname"
ms1.Col = 2
ms1.Text = "Address"
ms1.Col = 3
ms1.Text = "Phone no."
r=1
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program for currency conversion. The program should input the amount in
any currency and the output should be displayed in the desire currency as selected by
the
user. An input form should accept all the currency rates. The various currencies are
rupee,
dollar, pound and euro. (Use textbox control for input and to display output also)
Code:
Private Sub Command1_Click()
If Combo1.Text = "Rupees" Then
If Combo2.Text = "Rupees" Then Text2 = Text1 * InputBox("Enter the Rate for
Rupees...")
If Combo2.Text = "Dollars" Then Text2 = Text1 * InputBox("Enter the Rate for
Rupees...")
If Combo2.Text = "Pounds" Then Text2 = Text1 * InputBox("Enter the Rate for
Rupees...")
If Combo2.Text = "Euros" Then Text2 = Text1 * InputBox("Enter the Rate for
Rupees...")
End If
If Combo1.Text = "Dollars" Then
If Combo2.Text = "Rupees" Then Text2 = Text1 * InputBox("Enter the Rate for
Dollars...")
If Combo2.Text = "Dollars" Then Text2 = Text1 * InputBox("Enter the Rate for
Dollars...")
If Combo2.Text = "Pounds" Then Text2 = Text1 * InputBox("Enter the Rate for
Dollars...")
If Combo2.Text = "Euros" Then Text2 = Text1 * InputBox("Enter the Rate for
Dollars...")
End If
If Combo1.Text = "Pounds" Then
If Combo2.Text = "Rupees" Then Text2 = Text1 * InputBox("Enter the Rate for
Pounds...")
If Combo2.Text = "Dollars" Then Text2 = Text1 * InputBox("Enter the Rate for
Pounds...")
If Combo2.Text = "Pounds" Then Text2 = Text1 * InputBox("Enter the Rate for
Pounds...")
If Combo2.Text = "Euros" Then Text2 = Text1 * InputBox("Enter the Rate for
Pounds...")
End If
If Combo1.Text = "Euros" Then
If Combo2.Text = "Rupees" Then Text2 = Text1 * InputBox("Enter the Rate for
Euros...")

If Combo2.Text = "Dollars" Then Text2 = Text1 * InputBox("Enter the Rate for


Euros...")
If Combo2.Text = "Pounds" Then Text2 = Text1 * InputBox("Enter the Rate for
Euros...")
If Combo2.Text = "Euros" Then Text2 = Text1 * InputBox("Enter the Rate for Euros...")
End If
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program to accept the details of book, store those details into the database
and delete the particular record of given book id. (Use InputBox)
Code:
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
con.Open
rs.Open "book", con
rs.AddNew
rs.Fields(0) = Text1
rs.Fields(1) = Text2
rs.Fields(2) = Text3
rs.Update
rs.Close
con.Close
End Sub
Private Sub Command2_Click()
Dim n As Integer
Dim s1 As String
n = InputBox("enter book no ")
con.Open
s1 = "delete from book where bno=" & n & ""
con.Execute s1
con.Close
MsgBox "record deleted"
End Sub
Private Sub Command3_Click()
Text1 = ""
Text2 = ""
Text3 = ""
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\book.mdb;Persist Security Info=False"
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C
Roll no: 292
______________________________________________________________________________
Write a VB Program to display all even and odd numbers from an array.
Code:
Private Sub Command1_Click()
Dim a() As Integer
n = InputBox("How many elements do u want to enter")
ReDim a(n)
Print "Array is : "
For i = 0 To n - 1
a(i) = Val(InputBox("Enter the Elements"))
Print a(i)
Next
Print "Even; Numbers; are: "
For i = 0 To n - 1
If a(i) Mod 2 = 0 Then
Print a(i)
End If
Next
Print "Odd; Numbers; are: "
For i = 0 To n - 1
If a(i) Mod 2 <> 0 Then
Print a(i)
End If
Next
End Sub

Output:

Name: Aditya Jha

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:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program to design following screen with validation name should contain character
only, mobile number should contain only 10 digit, Pin code should contain only 6 digit,
email id should contain @, . symbol

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:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program to accept the details of product (pno, pname, qty, price
totalprice)
store it into the database and update the quantity of product having pno is 100. (Dont
use Standard Data controls)
Code:
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Private Sub Command1_Click()
con.Open
Set rs = New ADODB.Recordset
rs.LockType = adLockOptimistic
rs.Open "product", con
rs.AddNew
rs.Fields(0) = Text1.Text
rs.Fields(1) = Text2.Text
rs.Fields(2) = Text3.Text
rs.Fields(3) = Text4.Text
rs.Fields(4) = Text3 * Text4
rs.Update
rs.Close
con.Close
End Sub
Private Sub Command2_Click()
con.Open
s1 = "update product set qty = 100,tot=100*price where pno=100"
MsgBox s1
con.Execute s1
con.Close
End Sub
Private Sub Form_Load()
Set con = New ADODB.Connection
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\vb
prog\slip13\prod_db.mdb;Persist Security Info=False"
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C
Roll no: 292
______________________________________________________________________________
Write a VB Program to create a POPUP menu. Menu are Color (sub menu- red, green, blue,
yellow), Font (Times New Roman, Verdana, Arial Black etc), Font Size (10, 11, 12 etc)
after clicking on particular menu changes should reflect on Label control.
Code:
Private Sub arial_Click()
Label1.FontName = "Arial"
End Sub
Private Sub arialblack_Click()
Label1.FontName = "Arial Black"
End Sub
Private Sub timesnewroman_Click()
Label1.FontName = "Times New Roman"
End Sub
Private Sub blue_Click()
Label1.ForeColor = vbBlue
End Sub
Private Sub green_Click()
Label1.ForeColor = vbGreen
End Sub
Private Sub red_Click()
Label1.ForeColor = vbRed
End Sub
Private Sub fontsize10_Click()
Label1.fontsize = 10
End Sub
Private Sub fontsize11_Click()
Label1.fontsize = 11
End Sub
Private Sub fontsize12_Click()
Label1.fontsize = 12
End Sub

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


If Button = 2 Then PopupMenu menu
End Sub

Output:

Name: Aditya Jha

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:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program to store the details of players into the database and display that details using
ADODC.
Code:
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
End Sub
Private Sub Command2_Click()
Adodc1.Recordset.Update
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program to enter two positive numbers, calculate the sum of the products of
each pair of digits occupying the same position in the two numbers. Display the result
on
to the form.
Example:
If first number is 45 and second number is 534, then output will be 32.
(0*5 + 4*3 + 5*4 = 32)
Code:
Private Sub Command1_Click()
Dim x As Integer
Dim y As Integer
Dim r1 As Integer
Dim r2 As Integer
Dim s As Integer
x = Text1
y = Text2
If x > 0 And y > 0 Then
While x > 0 Or y > 0
r1 = x Mod 10
r2 = y Mod 10
s = s + r1 * r2
x = x \ 10
y = y \ 10
Wend
Label3.Caption = s
Else
Label3.Caption = "no is not positive"
End If
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB a program to enter Voters details and on next form disply Voters
Information and check proper validation for(name, age,nationality) as
Name should be in upper case letters
Age should not be less than 18 yrs.
Natinality should be Indian.
Code:
FORM 1:-Private Sub Command1_Click()
Form2.Show
End Sub
FORM 2:-Private Sub Form_Load()
Dim n, name, nation As String
Dim age As Integer
n = Form1.Text1
age = Val(Form1.Text2)
nation = UCase(Form1.Text3)
name = UCase(n)
If n <> name Then
Label3.Caption = Label3.Caption + "Name should be upper case only, "
Else
Label4.Caption = Label4.Caption + "Name is in Upper case,"
End If
If age < 18 Then
Label3.Caption = Label3.Caption + "Age <18 not allowd,"
Else
Label4.Caption = Label4.Caption + "Age ok,"
End If
If nation <> "INDIAN" Then
Label3.Caption = Label3.Caption + ", Nationality must be indian only"
Else
Label4.Caption = Label4.Caption + "Nationality ok"
End If
If Label3.Caption = "" Then Label3.Caption = "All input are correct..Thank you "
If Label4.Caption = "" Then Label4.Caption = "Failed"
End Sub
Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB Program to move a command button by using timer control.
Code:
Private Sub Timer1_Timer()
If Command1.Left = 2000 Then
Command1.Left = 240
Else
Command1.Left = Command1.Left + 20
End If
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program, i.e. menu driven that facilitates following task in a hotel
1. Reserves a room for a date
2. Cancel the reservation
3. Checkout, print bill on the checkout
4. List of all booked rooms.
Assume that the hotel contains 5 rooms
Code:
Private Sub booked_Click()
Adodc1.Refresh
End Sub
Private Sub cancel_Click()
Adodc1.Recordset.Delete
End Sub
Private Sub checkout_Click()
Dim s, n As Integer
s=0
n = InputBox("Enter the Price of Room")
s = Val(Text3) * n
MsgBox "The Total Amount is=" & s
End Sub
Private Sub reserv_Click()
Adodc1.Recordset.AddNew
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program to design progress bar using Timer control. Once process is completed
new form should get open and display message Processed Successfully
Code:
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If ProgressBar1.Value = ProgressBar1.Max Then
Form2.Show
Unload Me
Else
ProgressBar1.Value = ProgressBar1.Value + 10
End If
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program which accepts First name and last name from user into two textboxes and
three command buttons Concatenate, Uppercase, Lowercase respectively. After clicking
on command button appropriate result should get display into third textbox.
Code:
Private Sub Command1_Click()
Text3 = Text1 + Text2
End Sub
Private Sub Command2_Click()
Text3 = UCase(Text1)
End Sub
Private Sub Command3_Click()
Text3 = LCase(Text2)
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a menu driven program in VB for
i.
Addition
ii.
Subtraction
iii.
Multiplication
iv.
Division
Code:
Private Sub add_Click()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub
Private Sub div_Click()
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End Sub
Private Sub mult_Click()
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End Sub
Private Sub sub_Click()
Text3.Text = Val(Text1.Text) - Val(Text2.Text)
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write VB program to design following form

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

Private Sub Command1_Click()


Picture1.Picture = LoadPicture("C:\Users\Public\Pictures\Sample
Pictures\Chrysanthemum.jpg")
End Sub
Private Sub Command2_Click()
Picture1.Picture = LoadPicture("C:\Users\Public\Pictures\Sample
Pictures\Chrysanthemum.jpg")
End Sub
Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
Option1.Value = False
Option2.Value = False
Option3.Value = False
Option4.Value = False
Check1.Value = 0
Check2.Value = 0
Check3.Value = 0
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Option1_Click()
If Option1.Value = True Then Text1.ForeColor = vbRed
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then Text1.ForeColor = vbGreen
End Sub
Private Sub Option3_Click()
If Option3.Value = True Then Text1.ForeColor = vbBlue
End Sub
Private Sub Option4_Click()
If Option4.Value = True Then Text1.ForeColor = vbBlack
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C
Roll no: 292

______________________________________________________________________________
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:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program to accept the details of students from user & store details in to the
database. Using data environment create report. (Use standard ADODC controls)
Student (S_Rollno, S_Name, S_Class, S_Address )
Code:
Private Sub Command1_Click()
Adodc1.Recordset.AddNew
End Sub
Private Sub Command2_Click()
Adodc1.Recordset.Save
End Sub
Private Sub Command3_Click()
DataReport1.Show
End Sub
Private Sub Command4_Click()
Unload Me
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C
Roll no: 292
______________________________________________________________________________
Write a VB program to accept Input from Textbox. Check whether given input is alphabet or
number. If it is alphabet check that it is in uppercase or lowercase. Display appropriate
result using msgbox.
Code:
Private Sub Command1_Click()
If IsNumeric(Text1) Then
MsgBox "Textbox has numerica data"
Else
If Text1 = UCase(Text1) Then
MsgBox "Text is in upper case"
Else
MsgBox "Text is in lower case"
End If
End If
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB Program to accept the details of Professor (P_Name, P_Address, P_Bloodgroup,
P_Phoneno) Display those details on to the screen using data report.(Dont use standard
controls).
Code:
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Command1_Click()
rs.LockType = adLockOptimistic
con.Open
rs.Open "professsor", con
rs.AddNew
rs.Fields(0) = Text1
rs.Fields(1) = Text2
rs.Fields(2) = Text3
rs.Fields(3) = Text4
rs.Update
rs.Close
con.Close
End Sub
Private Sub Command2_Click()
DataReport1.Show
End Sub
Private Sub Command3_Click()
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Form_Load()
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents
and Settings\pract\My Documents\prodb.mdb;Persist Security Info=False"
End Sub
Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program that takes a set of ten numbers and converts them into either a bar
or pie chart using appropriate button.
Code:
Private Sub Command1_Click()
MSChart1.RowCount = 10
MSChart1.ColumnCount = 1
For i = 1 To 10
MSChart1.Row = i
MSChart1.Data = InputBox("Enter Data")
Next
End Sub
Private Sub Option1_Click()
MSChart1.chartType = VtChChartType2dBar
End Sub
Private Sub Option2_Click()
MSChart1.chartType = VtChChartType2dPie
End Sub

Output:

chart

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a menu driven program in VB for reservation & cancellation of tickets for a theatre. 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 (balcony, upper
& lower) (Use a List Box).Display no. of tickets booked, Category & total amount. The
reservation details should display no. of tickets booked at any instant of time categorywise.
Code:
Private Sub an_Click()
Adodc1.Recordset.AddNew
End Sub
Private Sub cticket_Click()
Adodc1.Recordset.Delete
End Sub
Private Sub rticket_Click()
Adodc1.Recordset.Save
End Sub
Private Sub sb_Click()
Adodc2.Refresh
DataGrid1.Refresh
DataGrid1.Visible = True
End Sub

Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB program to add five checkboxes at runtime which represents the hobbies, select
appropriate hobbies and display result on form.
Code:
Private Sub Command1_Click()
Load Check1(1)
Check1(1).Caption = "Cricket"
Check1(1).Visible = True
Check1(1).Top = Check1(0).Top + 600
Check1(1).Height = Check1(0).Height
Check1(1).Left = Check1(0).Left
Load Check1(2)
Check1(2).Caption = "Football"
Check1(2).Visible = True
Check1(2).Top = Check1(1).Top + 600
Check1(2).Height = Check1(0).Height
Check1(2).Left = Check1(0).Left
Load Check1(3)
Check1(3).Caption = "Running"
Check1(3).Visible = True
Check1(3).Top = Check1(2).Top + 600
Check1(3).Height = Check1(0).Height
Check1(3).Left = Check1(0).Left
Load Check1(4)
Check1(4).Caption = "Reading"
Check1(4).Visible = True
Check1(4).Top = Check1(3).Top + 600
Check1(4).Height = Check1(0).Height
Check1(4).Left = Check1(0).Left
End Sub
Private Sub Command2_Click()
Dim s As String
For i = 0 To 4
If Check1(i).Value = 1 Then s = s + Check1(i).Caption + ", "
Next
Label3.Caption = s
End Sub
Output:

Name: Aditya Jha


Class: SYBCA C

Roll no: 292


______________________________________________________________________________
Write a VB Program to design following screen which contain static value for size,
As per selection bill will be displayed.

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:

Você também pode gostar