You are on page 1of 33

# Q1) Write a program to perform following operation: 12345ADD SUBTRACT MULTIPLY DIVISION MOD

Private Sub cmdCalculateSum_Click() lblDisplay.Caption = Val(txtA.Text) & " + " & Val(txtB.Text) & " = " & (Val(txtA.Text) + Val(txtB.Text)) End Sub

Private Sub cmdDivide_Click() lblDisplay.Caption = Val(txtA.Text) & " / " & Val(txtB.Text) & " = " & (Val(txtA.Text) / Val(txtB.Text)) End Sub Private Sub cmdMultiply_Click() lblDisplay.Caption = Val(txtA.Text) & " * " & Val(txtB.Text) & " = " & (Val(txtA.Text) * Val(txtB.Text)) End Sub Private Sub cmdSubtract_Click() lblDisplay.Caption = Val(txtA.Text) & " - " & Val(txtB.Text) & " = " & (Val(txtA.Text) - Val(txtB.Text)) End Sub

1

OUTPUT: -

2

Q2) Write a program to print the number is even or odd? Dim A as Integer Dim even, odd As Integer Private Sub Command1_Click () A = Text1.Text If a > 0 Then If a Mod 2 = 0 Then Label2.Caption = "The Number is Even” & A Else Label2.Caption = " The Number is ODD " & A End If Else MsgBox ("Enter the Number Greater than Zero (0)") End If End Sub

OUTPUT:-

3

Q3) Write a program to find the greatest number from three numbers? Private Sub Form_Load() Dim a As Double Dim b As Double Dim c As Double a = Val(InputBox("Enter the first number: ")) b = Val(InputBox("Enter the second number: ")) c = Val(InputBox("Enter the third number: ")) If a >= b And a >= c Then MsgBox ("The greatest number is " & a) ElseIf b >= a And b >= c Then MsgBox ("The greatest number is " & b) ElseIf c >= a And c >= b Then MsgBox ("The greatest number is " & c) End If Unload Me End Sub OUTPUT:- 4 .

5 .

") Unload Me End Sub 6 . " & i sum = sum + i End If End If Next i MsgBox ("The numbers are " & numbers & " and their sum is " & sum & ".Q4) Write a program to print first n square less than 50 and print the sum of the all the square of the n number? Private Sub Form_Load() ' Print the first n squares less than 50 Dim i As Integer Dim upperlimit As Integer Dim numbers As String Dim sum As Integer upperlimit = Val(InputBox("Enter the upper limit for squares:")) numbers = "" For i = 1 To upperlimit If (i * i < upperlimit) Then If numbers = "" Then numbers = i sum = sum + i Else numbers = numbers & ".

OUTPUT: - 7 .

Caption = "THE FACOTRIAL OF THE NUMBER IS:" & "" & fact End Sub 8 .Text) For I = 1 To A fact = fact * I Next I Label3.Q5) Write a program to print factorial number? Dim I As Integer Dim A As Double Dim fact As Double Private Sub Command1_Click() fact = 1 A = Val(Text1.

OUTPUT:- 9 .

.Text For i = 1 To a ........ Private Sub Command1_Click() Dim i As Double Dim a As Double Dim temp As Double Dim temp1 As Double temp = 0 temp1 = 0 temp1 = 3 a = Text1....Caption = temp End Sub 10 .......Q6) Write a program to print the series 0+1\3+1\5+1\8+1\11.....1 Step 1 temp = temp + 1 / temp1 If temp1 \ 2 = 0 Then temp1 = temp1 + 3 Else temp1 = temp1 + 5 End If Next i Label2.............

Visible = True Then Label4.Visible = False Else Label4.Visible = True End If End Sub OUTPUT:- 11 .Private Sub Timer1_Timer() If Label4.

Text) temp = Val(Text2.Q7) Write a program to print the series Dim I.Text) fact = 1 sum = 1 For I = 2 To A For j = 1 To I fact = fact * j Next j sum = sum + ((temp * (j . j As Double Dim A As Double Dim temp As Double Dim sum As Double Dim fact As Double Private Sub Command1_Click() A = Val(Text1.2)) / fact) MsgBox (sum) Next I Label3.Caption = sum End Sub Private Sub Timer1_Timer() 12 .

Visible = True Then Label4.If Label4.Visible = True End If End Sub OUTPUT:- 13 .Visible = False Else Label4.

Clear a = Val(Text1.Clear For i = a To 0 Step -1 list1.Q8) Write a program to print the series in ascending order and in descending order by using for loop? Dim i As Integer Dim a As Double Dim series As Double Private Sub Command1_Click() list1.AddItem (i) Next i End Sub Private Sub Command2_Click() a = Val(Text1.AddItem (i) Next i End Sub 14 .Text) list1.Text) For i = 0 To a Step 1 list1.

OUTPUT 15 .

Text l = Text2. clear. city As String Dim phn. pin As Double Private Sub Command1_Click () f = Text1. last name.Text = "" Text5.Text = "" Text2.. city. add.Caption = f & " " & l Label9. Make the display button as default button and clear as cancel button.Text = "" Label8.Text city = Text5. zip code.Text phn = Text3. Fields to be input by the user requires text boxes where information to be displayed belongs in label.Caption = "" End Sub 16 .Caption = add & ". Dim f." & pin End Sub Private Sub Command2_click () Text1.Text pin = Text6.Text add = Text4. l.Text = "" Text3.Text Label8. Provide tool tips.Caption = "" Label10.Q9) Create a project that allows the user to input information and then display the lines of output for a mailing label. Use text boxes for 1st name. street no. state.Caption = phn Label10. use command buttons for display.Text = "" Text4.Caption = "" Label9." & city & ".Text = "" Text6. print and exit.

OUTPUT:- 17 .

Enabled = True Frame2. Use text boxes with labels attached for catalog code.Text = "" Text2. Use two group of option button on the form enclosed each group in the frame. clear and exit. part no. Add command buttons for print.Enabled = True End Sub Private Sub command3_click () If MsgBox("Are You Sure You Want To Exit ?". money order or credit card. Private Sub command1_click () MsgBox ("Shipment Confirmed !!!!") End Sub Private Sub command2_click () Text1. Use a check box for new customer. vbYesNo) = vbYes Then End End If End Sub Private Sub Command4_Click () MsgBox ("Successfully Registered !!!!") End Sub 18 . page no.Text = "" Frame1. For 2nd frame use a caption of payment type and include buttons for check..Text = "" Text3. Make the clear button the cancel button and add tool tips.Q10) Design and code a project that has shipping information.. The 1st frame should have caption of shipping and contain button for express and ground.

Enabled = False Frame2.Enabled = True Frame2.Private Sub Option6_Click () If Option6.Enabled = True Then Frame1.Enabled = True End If End Sub 19 .Enabled = False End If End Sub Private Sub Option7_Click () If Option7.Enabled = True Then Frame1.

OUTPUT:- 20 .

Caption = "" End Sub Private Sub Command3_Click () If MsgBox("Are You Sure You Want To Exit ?".Caption = "" Label8. revised As Double Private Sub Command1_Click () amt = Text2.Q11) Create a project for book sales. title and price with labels. discount (15%) and discounted price.Text revised = amt . Dim amt.Text = "" Text3.Caption = amt Label8. Make command buttons for calculate.Text * Text3.Caption = revised End Sub Private Sub Command2_Click () Text1.(0.Text = "" Label7.15 * amt) Label7. Calculate total price. clear and exit. Make text boxes for quantity. vbYesNo) = vbYes Then End End If End Sub 21 .Text = "" Text2.

OUTPUT:- 22 .

" & rent End Sub Private Sub Command2_Click () Text1.Text = "" Text3.Caption = "" End Sub 23 . of days the car was used.Caption = "" Label10. zip code.Q12) Create a project for the local car rental agency that calculates rental charges. exit and calculate.Text total = final . The agency charge \$15 per day + \$0.Text = "" Text4.Text = "" Label9. address.50 per km. state.Text = "" Text5. use text boxes for customer name. city. Use labels to display the miles given and the total charges. Dim Starting As Double Dim final As Double Dim total As Double Dim day As Double Dim rent As Double Private Sub Command1_Click () final = Text4.Text = "" Text2.Caption = total & "km" Label10. Make command buttons for clear. beginning and ending audiometer reading and no.Caption = "Rs.Starting day = Text5.5) Label9.Text rent = (day * 15) + (total * 0.Text Starting = Text3.

vbYesNo) = vbYes Then End End If OUTPUT:- 24 .Private Sub Command3_Click () If MsgBox("Are You Sure You Want To Exit ?".

06 * sales) ded = 0. ded.Caption = "\$" & misc 25 .Caption = "\$" & net housing = 0.deduction Budget:Housing 30% of net pay Food and clothing 15% of net pay Entertainment 50% of net pay Miscellaneous 5% of net pay Use text boxes to input the employee name. net.Text gp = 900 + (0. Dim sales.ded Label12.Caption = "\$" & food Label15.18 * gp net = gp .05 * net Label13.Caption = "\$" & entertainment Label16. misc As Double Private Sub Command1_Click () sales = Text2.Caption = "\$" & housing Label14. gp.3 * net food = 0. Each employee will receive a basic pay of \$900 + sales commission of 6% of sales.15 * net entertainment = 0. amount of sales. Calculate a gross salary. Use calculates. Use labels to display the result and the calculation.Q13) Create a project that will input an employee salary. clear and exit command buttons. entertainment. deduction and net salary. After calculating the net paid calculate the budget amount of each category based on the % given. Bank pays \$900 Commission 6% of sales Gross pay Basic pay + Commission Deduction 18% of gross pay Net pay Gross pay . housing.5 * net misc = 0. food.

Text = "" Label12.Caption = "" Label14.Caption = "" Label13.Caption = "" End Sub Private Sub Command4_Click () If MsgBox("Are You Sure You Want To Exit ?". vbYesNo) = vbYes Then End End If End Sub 26 .Text = "" Text2.Caption = "" Label15.Caption = "" Label16.End Sub Private Sub Command2_Click () MsgBox ("Application 5") End Sub Private Sub Command3_Click () Text1.

OUTPUT:- 27 .

Before clearing the list. Dim i As String Private Sub Command1_Click() i = InputBox("Enter The Name Of Ice Cream To Be Added : ". display and exit. Display an error message if the user select remove without first selecting an ice-cream type. remove. Don’t allow a blank type to be added to the list.ListIndex = -1 Then MsgBox ("Please Select Ice Cream To Remove !!!") Else Combo1.RemoveItem Combo1. Use a drop down combo box to hold the ice-cream type and use command button to add. display a message to confirm the operation. clear.Q14) Maintain a list of types of ice creams. vbYesNo) = vbYes Then End End If End Sub 28 . "New Ice Cream") If i <> "" Then MsgBox ("Please Select Ice Cream Name !!!") Else Combo1.AddItem i MsgBox ("Ice Cream Added To List !!!") End If End Sub Private Sub Command2_Click() If Combo1.ListIndex MsgBox ("Ice Cream Removed From List !!!") End If End Sub Private Sub Command3_Click() If MsgBox("Are You Sure You Want To Exit ?".

OUTPUT:- 29 .

Coffee and Pepsi will be chosen by check box. Tea .Value = 1 Then tea = 5 sum = sum + tea End If If Check3.Value = 1 Then pepsi = 20 sum = sum + pepsi End If 30 . The items like samosa.Value = 1 Then coffee = 8 sum = sum + coffee End If If Check4. Total amount should be displayed in label.Value = 1 Then samosa = 7 sum = sum + samosa End If If Check2. Dim tea As Integer Dim samosa As Integer Dim coffee As Integer Dim sum As Integer Dim pepsi As Integer Private Sub Command1_Click() sum = 0 samosa = 0 tea = 0 coffee = 0 pepsi = 0 If Check1.Q15) Create a project for a Tea cafe to calculate the bill.

Label3.Value = 0 End Sub End If End Sub OUTPUT:- 31 .Value = 0 Check3.Caption = sum Check1.Value = 0 Check2.Value = 0 Check4.

Next j Print Next i End Sub OUTPUT:- 32 .Q16-A) Write a program to print them: AAAAAAAA BBBBBBBB CCCCCC DDDDD EEEE FFF GG H Private Sub Command1_Click() Print Tab Print Tab Print Tab For i = 65 To 72 Step 1 For j = i To 72 Step 1 Print Chr(i).

Q16 – B) Write a program to print them: 33 .