Вы находитесь на странице: 1из 13

1|Page Visual Basic 6.

0 Punjab University papers

Visual Basic 6.0 2007

Question No 1(a). What is an algorithm and pseudo code? 5.0


1(b). What is OOP? Explain its importance 5.0
Question No 2(a) what are user define data types? which data type are support to VB 5.0
2(b) what are control element? Explain the sub procedure . 5.0
Question NO.3(a) what are optional arguments ? Write code example using optional arguments
3(b) what are event procedure .with example . 5.0 + 5.0
Question No 4.(a) what are arrays? Explain two array related functions 5.0
4.(b) what are difference between logical and syntax error with example 5.0
Question No 5.(a) what are sequential Access data file ? 5.0
5.(b) what is a data base ? explain the uses of data control 5.0
Visual Basic 6.0 2008
Question No 1(a). Differentiate between structured programming and OOP 5.0+ 5.0
1(b). what is variable ? in visual basic what do you mean by scope of variable.
Question No 2(a) what do you means by a user defined sub procedure. Explain by giving
example 5.0
2(b) differentiate between input box function and msgbox function. 5.0
Question NO.3(a) what are the different looping construct available in visual basic with
example 5.0
3(b) what are the different selection structure available in visual basic with
Example 5.0
Question No 4.(a) what do you means control array . In visual basic how control arrays help 5.0
you in coding. 5.0
4.(b) write a descriptive note on sequential access of file . 5.0
Question No 5.(a) An array of size N contains N positive integer 0-9construct an algorithm to
determine if word is palindrome (mom , 4994) 5.0
5.(b) write the program to read a positive integer N whether or not N is prime
Number. 5.0

Solution:-
Private Sub Command1_Click()
Dim i As Integer
Dim x As Integer
n = InputBox("enter the value ")
For i = 2 To n / 2
If n Mod i = 0 Then
x=1
Exit For

http://informationtechnology.pk
2|Page Visual Basic 6.0 Punjab University papers

End If
Next i
If x = 0 Then
Print "prime"
Else
Print "composite"
End If
End Sub

Visual Basic 6.02009


Question no 1(a). What is program solving ? explain its advantages . 5.0
1(b) What is variable ? explain different data types in VB. 5.0
Question No 2. (a) What are arithmetic operator in visual basic ? explain with example.`5.0
2(b) How can you use a scrollbar in visual basic with example . 5.0
Question No 3(a) What is user define data types explain with example . 5.0
3(b) In visual basic how select case help in coding . 5.0
Question no 4 (a) Discuss the different properties of form in detail . 5.0
4 (b) Difference between modules and procedure 5.0

Visual Basic 6.0 2010


Question No .1 what is event driven programming ? differentiate between event driven
programming and visual programing . 12.5

Question no 2. Write a VB program that takes n numbers as input . it outputs the frequency of
positive and negative numbers . A sample input and out put as follows:-. 12.5

Input

N = 12

The 12 numbers are as under :-

40 , 0 , -1 , 59 , -37 , 283 , 61 , 387 , -91 , -103 , 341 , 523

Output :-

Frequency of positive numbers :- 8

Frequency of negative numbers :- 4

Solution:-
Private Sub Command1_Click()
Dim n(11) As Integer

http://informationtechnology.pk
3|Page Visual Basic 6.0 Punjab University papers

Dim sumpos As Integer


Dim sumneg As Integer
For i = 0 To 11
n(i) = InputBox("enter the value of array:")
Next i
For i = 0 To 11
Print n(i)
If n(i) < 0 Then
sumneg = sumneg + 1
Else
sumpos = sumpos + 1
End If
Next i
Print "the frequency of even " & sumpos
Print " the frequency of odd " & sumneg
End Sub

Question NO 3. Write a VB program that reads n values in a list and print the product of the value
and position at which it resides in the list . product = L[1]*1 , product = L[2] * 2 and so on

Note the list does not change :- 12.5

Example:- position :- 1 2 3 4 5
Value 5 3 7 1 4
Output :- 5 6 21 4 20
Solution :-
Private Sub Command1_Click()
Dim n(1 To 5) As Integer
For i = 1 To 5
n(i) = InputBox("enter the values in to array")
Next i
Print " the output is as follwoing:"
For i = 1 To 5
Print n(i) * i
Next i
End Sub

Visual Basic 6.0 2011


Question no 1. What is meant by structure programming? Describes event procedures , function
procedures and modules . also given one coding for each type of the procedure . 12.5
Solution:-

http://informationtechnology.pk
4|Page Visual Basic 6.0 Punjab University papers

Question no . 2 write a VB program that takes N numbers as input . it print the maximum
number and its frequency (number of occurrence ) . 12.5

Sample no 1
N= 10
The 10 inputs are 7,20 , -1 , 65 , 36 , 90, 78 , 90 ,90 ,-2
Maximum is 90
Frequency is 3
Solution :-

Private Sub Command1_Click()


Dim fr As Integer
Dim i As Integer
Dim n As Integer
Dim max As Integer
fr = 0
max = 0
n = InputBox("enter the values")
For i = 1 To n
x = InputBox("enter the value ")
If x > max Then
max = x
fr = 1
ElseIf x = max Then
fr = fr + 1
End If
Next i
Print "max is =" & max
Print "frequency of max value" & fr
End Sub
Question no 3 . Write a program that read 10 numbers from user and store them in an array. Print
the numbers in ascending order . A sample program is given below . 12.5

7,8,90,34,2,9,12,1,10,32
Output :-
1,2,7,8,9,10,12,32,34,90
Solution:-
Private Sub Command1_Click()
Dim arr(4) As Integer, temp As Integer
Dim s As Integer
Dim e As Integer
s = InputBox("enter the value of s")
e = InputBox("enter the value of e")
For i = s To e

http://informationtechnology.pk
5|Page Visual Basic 6.0 Punjab University papers

arr(i) = InputBox("enter the time in min")


Next i
For i = s To e
Print arr(i)
Next i
For i = s To e
For j = s To e - 1
If arr(j) > arr(j + 1) Then
temp = arr(j)
arr(j) = arr(j + 1)
arr(j + 1) = temp
End If
Next j
Next i
Print "sorted array "
For i = s To e
Print arr(i)
Next i
End Sub

Visual Basic 6.0 2012


Question no .1 Explain the following programming concept with example :- 12.5
a. data types in visual basic
b. variables and their scope in a program
c. branching & looping instructions
d. function procedure
e. relational operator .

Question no .2 write a VB program that should takes a number n as input . your program print first
10 multiples of n by using loop . 12.5
Solution :-
Private Sub Command1_Click()
Dim n As Integer
n = InputBox("enter the value of n")
For i = 1 To 10
Print "multiple" & n * i
Next i
End Sub

http://informationtechnology.pk
6|Page Visual Basic 6.0 Punjab University papers

Question no . 3 write a VB program that should takes 10 numbers as input and store them in an
array. It should print the number of even numbers among those numbers . you need to use if –else
and loop in your program . 12.5
Solution :-
Private Sub Command1_Click()
Dim n(9) As Integer
Dim sumeven As Integer
sumeven = 0
For i = 0 To 9
n(i) = InputBox("enter the value of n")
Next i
For i = 0 To 9
If n(i) Mod 2 = 0 Then
Print n(i)
sumeven = sumeven + 1
End If
Next i
MsgBox "total even number frequency=" & sumeven
End Sub

Visual Basic 6.0 2013


Question no 1. Explain the following terms and techniques :- 12.5
a. low level language
b. OOP
c. Structured programming
d. sub procedure
e. variable in VB
Question No 2. Write a VB program that should takes 10 numbers from user as input data . your
program should separate count the even and odd numbers presents in input . print both of the
counts on the screen . 12.5
Solution :-
Private Sub Command1_Click()
Dim n(9) As Integer
For i = 0 To 9
n(i) = InputBox("enter the value of array:")
Next i
For i = 0 To 9
Print n(i)
If n(i) Mod 2 = 0 Then

http://informationtechnology.pk
7|Page Visual Basic 6.0 Punjab University papers

evensum = evensum + 1
Else
oddsum = oddsum + 1
End If
Next i
Print "the frequency of even " & evensum
Print " the frequency of odd " & oddsum
End Sub

Question No 3. Write a program in VB that should takes 3 numbers from user as input . your
program find and print the square and cube of these three numbers on the screen . 12.5
Solution :-
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
a = InputBox("enter the value of a ")
b = InputBox("enter the value of b ")
c = InputBox("enter the value of c ")
Print "a =" & vbTab & a ^ 2 & vbTab & a ^ 3; vbNewLine & "b =" & vbTab & b ^ 2 & vbTab &
b ^ 3; vbNewLine & "c =" & vbTab & c ^ 2 & vbTab & c ^ 3; vbNewLine
End Sub

Visual Basic 6.0 2014


Question NO .1. briefly explain the different between the following terms :- (6.0 + 6.5)
1. variable and constant

2. low level and high level programming language

3. conditional and repletion statement in VB

(B) write a VB program that inputs three distinct number and find and display middle one .

Solution :-

http://informationtechnology.pk
8|Page Visual Basic 6.0 Punjab University papers

Private Sub Command1_Click()


Dim a As Integer
Dim b As Integer
Dim c As Integer
a = InputBox("enter the value")
b = InputBox("enter the value")
c = InputBox("enter the value")
If (a > b And a < c) Or (a < b And a > c) Then
Print "a is middile value"
ElseIf (b > a And b < c) Or (b < a And b > c) Then
Print " b is middle value"
ElseIf (c > a And a < b) Or (c > b And a < c) Then
Print "c is middle value"
End If
End Sub
Question No 2(a) The Area of a rectangle is the rectangle’s multiplied by its width . write program
that asks for length and width of two rectangles . The program should tell the user which rectangle
has the greater area or if the area are the same . (6.0+6.5)
Solution :-
Private Sub Command1_Click()
Dim l1 As Integer
Dim l2 As Integer
Dim w1 As Integer
Dim w2 As Integer
Dim a1 As Integer
Dim a2 As Integer
l1 = InputBox("enter the value of lenght 1st triangle")
w1 = InputBox("enter the value of width 1st triangle")
l2 = InputBox("enter the value of lenght 2nd triangle")
w2 = InputBox("enter the value of width 2nd triangle ")
a1 = l1 * w1
a2 = l2 * w2
If a1 > a2 Then
MsgBox ("area of first triangle is greater from second triangle ")
ElseIf a1 = a2 Then
MsgBox ("area of first triangle is equal to second triangle")
ElseIf a1 < a2 Then
MsgBox ("area of second triangle is greater from first triangle ")
End If
End Sub

http://informationtechnology.pk
9|Page Visual Basic 6.0 Punjab University papers

(b) . Write a VB program that should take a positive number n as input . your should display the
sum of all numbers between 1 to n numbers .

Solution : -
Private Sub Command1_Click()
Dim n As Integer
Dim sum As Integer
n = InputBox("enter the value")
For i = 1 To n
num = InputBox("enter the value")
Print num
sum = sum + num
Next i
Print "sum of all the num" & sum
End Sub

Question NO 3.(a) write a VB program that should take 10 number from user . your program
should find and display the maximum number . (6.0+6.5)
Solution:-
Private Sub Command1_Click()
Dim num As Integer
Dim max As Integer
Dim count As Integer
count = 0
max = num
num = InputBox("enter the value :")
Do While num > 0
count = count + 1
If num > max Then
max = num
End If
num = InputBox("enter the value for exit ")
Loop
Print "max num is = " & max
End Sub

OTHER SOLUTION
Private Sub Command1_Click()
Dim n(10) As Integer
Dim max As Integer

http://informationtechnology.pk
10 | P a g e Visual Basic 6.0 Punjab University papers

For i = 1 To 10
n(i) = InputBox("enter the 10 value")
Next i
max = n(1)
For i = 1 To 10
Print n(i)
If max < n(i) Then
max = n(i)
End If
Next i
Print "max =" & max
End Sub

(b) write a program that should takes two numbers (that is , first and last ) from the user and display
all the numbers and their square in the form of an order pair between first and last numbers

For example if user enter 2 to 5 then it should display pairs

(2,4) (3,9) (4,16) (5,25)

For example if user enter -3 to1 then it should display pairs

(-3 ,9) (-2,4) (-1 ,1) (0,0) )(1,1)

Solution :-

Private Sub Command1_Click()


Dim n As Integer
Dim S As Integer
Dim E As Integer
S = InputBox("enter the value")
E = InputBox("enter the value")
n=S
For n = S To E
Print "(" & n & "," & n ^ 2 & ")"
Next n
End Sub

http://informationtechnology.pk
11 | P a g e Visual Basic 6.0 Punjab University papers

Visual Basic 6.0 2015


Question NO 1(a) briefly Explain the difference between the following terms (6.0+6.5)
1. structured programming

2. object oriented programming

3. visual programming

Question No 1(b) running on a particular treadmill burn 3.9 calories per minutes . write a program
that uses a loop to display the number of calories burned after 10, 15 ,20 , 25 and 30 minutes

Solution:-
Private Sub Command1_Click()
Dim calories As Single
Dim total_cal As Double
total_cal = 0
calories = InputBox("enter the calories")
For i = 10 To 30 Step 5
Print calories * i
total_cal = total_cal + calories * i
Next i
Print "total calories" & total_cal
End Sub
With constant
Private Sub Command1_Click()
Const calories As Single = 3.9
Dim total_cal As Double
total_cal = 0
For i = 10 To 30 Step 5
Print calories * i
total_cal = total_cal + calories * i
Next i
Print "total calories" & total_cal
End Sub

Question NO 2(a) A country club , which currently charge RS. 2500 per year for membership has ,
announced it will increase its membership fee by 4% each year for next 6 years . write a program
uses loop to display the projected for next six years. (6.0+6.5)
Solution:-
Private Sub Command1_Click()
Dim membership As Integer

http://informationtechnology.pk
12 | P a g e Visual Basic 6.0 Punjab University papers

Dim sum As Integer


Dim year As Integer
sum = 0
membership = 2500
For year = 2011 To 2016
Print year & vbTab & membership * 0.04
sum = sum + membership * 0.04
projected_cost = membership + sum
Next year
Print "projected membership for next 6 years " & projected_ cost
End Sub

Question No 2(b) write a VB program that should takes 10 positive numbers as input . your
program should display the sum of all the numbers from 1 to n numbers .

Solution:-
Private Sub Command1_Click()
Dim n As Integer
Dim sum As Integer
sum = 0
For i = 1 To 10
n = InputBox("enter the value")
Print n
sum = sum + n
Next i
Print "sum of numbers" & sum
End Sub

Question NO 3(a) write a VB program that should takes 10 minutes from user and save in an array
. your program should sort and display these numbers in ascending order. (6.0+6.5)
Private Sub Command1_Click()
Dim arr(4) As Integer, temp As Integer
Dim s As Integer
Dim e As Integer
s = InputBox("enter the value of s")
e = InputBox("enter the value of e")
For i = s To e
arr(i) = InputBox("enter the time in min")
Next i
For i = s To e
Print arr(i)
Next i

http://informationtechnology.pk
13 | P a g e Visual Basic 6.0 Punjab University papers

For i = s To e
For j = s To e - 1
If arr(j) > arr(j + 1) Then
temp = arr(j)
arr(j) = arr(j + 1)
arr(j + 1) = temp
End If
Next j
Next i
Print "sorted array "
For i = s To e
Print arr(i)
Next i
End Sub
Question N0 .3(b) write a program that asks the user to enter the amount that he or she budgeted
for a month . A loop should then user to enter each of his or her expenses for the month and keep a
running total . when the loop finishes , the program should displays the amount that user is over
or under the budgets .

Solution:-
Private Sub Command1_Click()
Dim budget As Integer
Dim val As Integer
Dim exp As Integer
exp = 0
budget = InputBox("enter the budget")
Do
val = InputBox("enter the expenses or enter the 0 to end ")
exp = exp + val
Loop While (val <> -1)
If budget > exp Then
Print " expenses under the budget"
Else
Print " expenses over the budget"
End If
End Sub

http://informationtechnology.pk

Вам также может понравиться