Top Banner

of 62

Vinay Singh Vb File Complete

Jul 10, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript

Q1 Create a project that allows the user to input information and then display the lines of output for a mailing label. Fields to be input by the user requires text boxes where information to be displayed belongs in label. Use text boxes for 1st name, last name, street no., city, state, zip code. Provide tool tips, use command buttons for display, clear, print and exit. Make the display button as default button and clear as cancel button.Private Sub Command1_Click() Dim a, b, d, e, f As String 'Dim b As String Dim c As Variant 'Dim d As String 'Dim e As String 'Dim f As String a = Text1.Text b = Text2.Text c = Text3.Text d = Text4.Text e = Text5.Text f = Text6.Text Label8.Caption = "Your name is " & a & " " & b & Chr(13) & " Your street no is " & c _& " City " & d + Chr(13) + " State " & e + " Zip code " + f_ End sub

Q2 Design and code a project that has shipping information. Use text boxes with labels attached for catalog code, page no., part no.. Use two group of option button on the form enclosed each group in the frame. The 1st frame should have caption of shipping and contain button for express and ground. For 2nd frame use a caption of payment type and include buttons for check, money order or credit card. Use a check box for new customer. Add command buttons for print, clear and exit. Make the clear button the cancel button and add tool tips.Private Sub Command1_Click() Dim a, b, c As Integer Dim d, e As String a = Text1.Text b = Text2.Text c = Text3.Text If Check1.Value = 1 Then d = "New coustomer" ElseIf Check1.Value = 0 Then d = "Old coutomer" End If If Option1.Value = True Then e = "express" ElseIf Option2.Value = True Then e = "ground" End If If Option3.Value = True Then f = "check " ElseIf Option4.Value = True Then f = "money order or credit" End If Label5.Caption = "code " + Str(a) + Chr(13) + " page number" + Str(b) + Chr(13) + " part no " + Str(c) + Chr(13) + d + Chr(13) + " shipping " & e + Chr(13) + " payment " & f End Sub Private Sub Form_Load() Check1.Value = 0 End Sub

Q3 Create a project for book sales. Make text boxes for quantity, title and price with labels. Calculate total price, discount (15%) and discounted price. Make command buttons for calculate, clear and exit.Private Sub Command1_Click() Dim a As Integer Dim b As Double Dim t As Double Dim d As Double a = Text2.Text b = Text3.Text t=a*b Text4.Text = t d = (t * 15) / 100 Text5.Text = d t=t-d Text6.Text = t End Sub Private Sub Command2_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" End Sub Private Sub Command3_Click() End End Sub

Q4 Create a project for the local car rental agency that calculates rental charges. The agency charge $15 per day + $0.50 per km. use text boxes for customer name, address, city, state, zip code, beginning and ending audiometer reading and no. of days the car was used. Use labels to display the miles given and the total charges. Make command buttons for clear, exit and calculate.Private Sub Command1_Click() Dim k, t As Double Dim d, m As Integer k=1 d = Text9.Text m = Text8.Text k = m * 0.5 d = d * 15 t=k+d Label11.Visible = True Label12.Visible = True Label11.Caption = " TOTAL NUMBERS OF KILOMETERS ARE " + Str(m) Label12.Caption = " TOTAL CHARGES ARE " + Str(t) End Sub Private Sub Command2_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" Text7.Text = "" Text8.Text = "" Text9.Text = "" Label11.Visible = False Label12.Visible = False End Sub Private Sub Command3_Click() End End Sub

Q 6 Maintain a list of types of ice creams. Use a drop down combo box to hold the ice-cream type and use command button to add, remove, clear, display and exit. Dont allow a blank type to be added to the list. Display an error message if the user select remove without first selecting an ice-cream type. Before clearing the list, display a message to confirm the operation.Dim a, b, c, d As Integer Dim sum As Integer Private Sub Command1_Click() Label2.Caption = "tatol bill is " + Str(sum) End Sub Private Sub Form_Load() List1.AddItem "VALLINA 30 RS" List1.AddItem "CHOCHABAR 40 RS" List1.AddItem "MANGO BAR 25 RS" List1.AddItem "VALLINA CUP 40 RS" List1.AddItem "STROBARRY 50 RS" List1.AddItem "APPLE FLAVOUR 30 RS" List1.AddItem "BANANA FLAVOUR 20 RS" List1.AddItem "PYENAPLE 20 RS" List1.AddItem "MANGO FLAVOUR 20 RS" List1.AddItem "SIMPLE CUP 10 RS" List1.AddItem "CONE 20 RS " End Sub Private Sub List1_Click() Combo1.AddItem List1.Text If List1.Selected(0) = True Then sum = sum + 30 ElseIf List1.Selected(1) = True Then sum = sum + 40 ElseIf List1.Selected(2) = True Then sum = sum + 25 ElseIf List1.Selected(3) = True Then sum = sum + 40 ElseIf List1.Selected(4) = True Then sum = sum + 50 ElseIf List1.Selected(5) = True Then sum = sum + 30 ElseIf List1.Selected(6) = True Then sum = sum + 20 ElseIf List1.Selected(7) = True Then sum = sum + 20 ElseIf List1.Selected(8) = True Then sum = sum + 20 ElseIf List1.Selected(9) = True Then sum = sum + 10 ElseIf List1.Selected(10) = True Then sum = sum + 20 End If

Text1.Text = sum End Sub

Q7 Create a project that contains a form for entering book information from controls. ext boxes for author and title. T Option button for type fiction or non-fiction. Dropdown list for subject that will include bestseller, fantasy, religion, romance, humor, science fiction, business, philosophy, education, self-help and mystery. List box for shelf no. containing RC-111, RC-112, RC-113, and RC-114. Use command buttons display, clear and exit. Use labels to display information.Private Sub Command1_Click() Form2.Label1.Caption = "BOOK TITLE NAME IS = " & Text1.Text Form2.Label2.Caption = "AUTHOR NAME IS = " & Text2.Text If Option1.Value = True Then Form2.Label3.Caption = " FICTION " ElseIf Option2.Value = True Then Form2.Label3.Caption = " NON FICTION " End If If Combo1.ListIndex = 0 Then Form2.Label4.Caption = "SUBJECT = " & Combo1.Text ElseIf Combo1.ListIndex = 1 Then Form2.Label4.Caption = "SUBJECT = " & Combo1.Text ElseIf Combo1.ListIndex = 2 Then Form2.Label4.Caption = "SUBJECT = " & Combo1.Text ElseIf Combo1.ListIndex = 3 Then Form2.Label4.Caption = "SUBJECT = " & Combo1.Text ElseIf Combo1.ListIndex = 4 Then Form2.Label4.Caption = "SUBLECT = " & Combo1.Text ElseIf Combo1.ListIndex = 5 Then Form2.Label4.Caption = "SUBJECT = " & Combo1.Text ElseIf Combo1.ListIndex = 6 Then Form2.Label4.Caption = "SUBJECT = " & Combo1.Text ElseIf Combo1.ListIndex = 7 Then Form2.Label4.Caption = "SUBJECT = " & Combo1.Text ElseIf Combo1.ListIndex = 8 Then Form2.Label4.Caption = "SUBJECT = " & Combo1.Text End If If List1.ListIndex = 0 Then Form2.Label5.Caption = "SELF NUMBER IS = " & List1.Text ElseIf List1.Selected(1) = True Then Form2.Label5.Caption = "SELF NUMBER IS = " & List1.Text ElseIf List1.Selected(2) = True Then Form2.Label5.Caption = "SELF NUMBER IS = " & List1.Text ElseIf List1.Selected(3) = True Then Form2.Label5.Caption = "SELF NUMBER IS = " & List1.Text End If Form2.Show 'Unload Me

End Sub Private Sub Command2_Click() Text1.Text = "" Text2.Text = "" End Sub Private Sub Command3_Click() End End Sub Private Sub Form_Load() Combo1.AddItem "BESTSELLER" Combo1.AddItem "FANTASY" Combo1.AddItem "RELIGION" Combo1.AddItem "ROMAN FICTION" Combo1.AddItem "BUSINESS" Combo1.AddItem "PHILOSAPHY" Combo1.AddItem "EDUCATION" Combo1.AddItem "SELF-HELP" Combo1.AddItem "MYSTERY" List1.AddItem "RC-111" List1.AddItem "RC-112" List1.AddItem "RC-113" List1.AddItem "RC-114" End Sub

Q 8 Create a list box, which contains names of all cinema halls of NCR. If you choose name of cinema hall, label display information regarding all movies running in the cinema halls.Private Sub Command1_Click() Label2.Caption = "" Label4.Caption = "" End Sub Private Sub Command2_Click() End End Sub Private Sub Form_Load() List1.AddItem "GIP" List1.AddItem "CSM" List1.AddItem "SPICE" List1.AddItem "PVR" End Sub Private Sub List1_Click() If List1.Selected(0) = True Then Label2.Caption = " GIP NOIDA" & Chr(13) & "show time 9:am,12:am,3:pm " & Chr(13) & "SEATS AVILABLE 20" Label4.Caption = " 3 Idiots" Label5.Visible = True ElseIf List1.Selected(1) = True Then Label2.Caption = "CSM NOIDA" & Chr(13) & "show time 9:am,12:am,3:pm " & Chr(13) & "SEATS AVILABLE 25" Label4.Caption = "AVTAR" Label5.Visible = True ElseIf List1.Selected(2) = True Then Label2.Caption = "SPICE NOIDA" & Chr(13) & " show time 9:am,12:am,3:pm " & Chr(13) & "SEATS ARE NOT AVILABLE" Label4.Caption = "VEER" Label5.Visible = True ElseIf List1.Selected(3) = True Then Label2.Caption = "PVR GHAZIABAD " & Chr(13) & "show time 9:am,12:am,3:pm " & Chr(13) & "ONLY ONE IS AVILABLE" Label4.Caption = "MY NAME IS KHAN" Label5.Visible = True End If End Sub

Q 9 Create a project that contains students information Text boxes to display name and courses. Option buttons for semester/ year. Use list boxes for computers, business, humanities, Commerce, medical and engineering. A simple combo for name of college. Display information on a label. Make command buttons for display, clear and exit.Private Sub Command1_Click() Text1.Text = "" Text2.Text = "" End Sub Private Sub Command2_Click() Form2.Label1.Caption = "STUDENT NAME = " & Text1.Text Form2.Label2.Caption = "COURSE = " & Text2.Text If Option1.Value = True Then Form2.Label3.Caption = "SEMESTER 1" ElseIf Option2.Value = True Then Form2.Label3.Caption = "SEMESTER 2" ElseIf Option3.Value = True Then Form2.Label3.Caption = "SEMESTER 3" ElseIf Option4.Value = True Then Form2.Label3.Caption = "SEMESTER 4" ElseIf Option5.Value = True Then Form2.Label3.Caption = "SEMESTER 5" ElseIf Option6.Value = True Then Form2.Label3.Caption = "SEMESTER 6" End If If Option7.Value = True Then Form2.Label4.Caption = "1 YEAR" ElseIf Option8.Value = True Then Form2.Label4.Caption = "2 YEAR" ElseIf Option9.Value = True Then Form2.Label4.Caption = "3 YEAR" End If If List1.Selected(0) = True Then Form2.Label5.Caption = "COMPUTERS" ElseIf List1.ListIndex = 1 Then Form2.Label5.Caption = List1.Text ElseIf List1.Selected(2) = True Then Form2.Label5.Caption = "HUMANITIES" ElseIf List1.Selected(3) = True Then Form2.Label5.Caption = "COMMERSE"

ElseIf List1.Selected(4) = True Then Form2.Label5.Caption = "MEDICAL" ElseIf List1.Selected(5) = True Then Form2.Label5.Caption = "ENGINEERING" End If If Combo1.ListIndex = 0 Then Form2.Label6.Caption = Combo1.Text ElseIf Combo1.ListIndex = 1 Then Form2.Label6.Caption = Combo1.Text ElseIf Combo1.ListIndex = 2 Then Form2.Label6.Caption = Combo1.Text ElseIf Combo1.ListIndex = 3 Then Form2.Label6.Caption = Combo1.Text ElseIf Combo1.ListIndex = 4 Then Form2.Label6.Caption = Combo1.Text ElseIf Combo1.ListIndex = 5 Then Form2.Label6.Caption = Combo1.Text End If Form2.Show End Sub Private Sub Command3_Click() End End Sub Private Sub Form_Load() List1.AddItem "COMPUTERS" List1.AddItem "BUSINESS" List1.AddItem "HUMANITIES" List1.AddItem "COMMERSE" List1.AddItem "MEDICAL" List1.AddItem "ENGINEERING" Combo1.AddItem "AMITY" Combo1.AddItem "IIT" Combo1.AddItem "IMT" Combo1.AddItem "DELHI UNIVERSITY" Combo1.AddItem "IIT KANPUR" Combo1.AddItem "IIM DELHI" End Sub

Q 10 Write a program, using recursive function to calculate Factorial of any no., also display the factorial of all no. smaller than that in a list boxOption Explicit Private Sub Command1_Click() Dim n As Double, x As Double n = Text1.Text For x = 0 To n Step 1 List1.AddItem Format$(x, "@@") & "! = " & factorial(x) Next x End Sub Private Function factorial(ByVal y As Double) As Double If y = b And a >= c Then Label5.Caption = Str(a) + " FIRST NUMBER IS GREATER NUMBER THEN OTHERS" ElseIf b >= a And b >= c Then Label5.Caption = Str(b) + " SECOND NUMBER IS GREATER NUMBER THEN OTHERS" Else Label5.Caption = Str(c) + " THIRD NUMBER IS GREATER NUMBER THEN OTHERS" End If End Sub Private Sub Command2_Click() End End Sub

Q Factorial and sum of n natural numbers .Dim n As Integer Dim fact As Integer Private Sub Command1_Click() If Option1.Value = True Then fact = 1 n = Val(InputBox("PLEASE ENTER NUMBER FOR CALCULATE FACTORIAL")) For i = 1 To n fact = fact * i Next i MsgBox ("factorial of number " + Str(n) + " is equal to " + Str(fact)) Else n = Val(InputBox("PLEASE ENTER NUMBER FOR SUM ")) fact = 0 For i = 1 To n fact = fact + i Next i MsgBox ("TOTAL SUM OF " + Str(n) + " IS EQUAL TO " + Str(fact)) End If End Sub Private Sub Command2_Click() Option1.Value = False Option2.Value = False End Sub Private Sub Command3_Click() End End Sub Private Sub Form_Load() Option1.Value = False Option2.Value = False End Sub

Q Canteen Billing SystemDim sum As Double Dim tax As Double Private Sub Command1_Click() If Check1.Value = 1 Then List1.AddItem "COFFEE 10" sum = sum + 10 End If If Check2.Value = 1 Then List1.AddItem "TEA 10" sum = sum + 10 End If If Check3.Value = 1 Then List1.AddItem "SAMUSA 10" sum = sum + 10 End If If Check4.Value = 1 Then List1.AddItem "RAJMA RISE 20" sum = sum + 20 End If If Check5.Value = 1 Then List1.AddItem "CHOLA RISE 20" sum = sum + 20 End If If Check6.Value = 1 Then List1.AddItem "GULAB JAMON 10" sum = sum + 10 End If tax = (sum * 5) / 100 List1.AddItem " BILL " + Str(sum) sum = sum + tax List1.AddItem " TAX " + Str(tax) List1.AddItem " TOTAL BILL " + Str(sum) Text1.Text = sum End Sub Private Sub Command3_Click() End End Sub