VB July 2019 Marking Scheme
VB July 2019 Marking Scheme
VB July 2019 Marking Scheme
VISUAL PROGRAMING
July 2019
Time: 3 hours
MODULE II
VISUAL PROGRAMMING
3 hours
INSTRUCTIONS TO CANDIDATES
Candidates should check the question paper to ascertain that all the
pages are printed as indicated and that no questions are missing.
©2019 The Kenya National Examinations Council. Turn over
2
1. (a) Outline a circumstance under which each of the following controls may be used in a Visual
Basic program.
(i) Timer;
(ii) Picturebox;
(iii) Checkbox; (3 marks)
(b) Explain the function of each of the following in a Visual Basic Integrated Development
Environment.
(i) Menu bar;
(ii) Object browser;
(iii) Form layout window. (6
marks)
(c) Distinguish between caption and name properties as used in a Visual Basic Program.(4 marks)
(d) Write a program in Visual Basic that uses functions to generate acceptable remarks based on
the average score that a student obtains in an examination as shown in Table 1. The program
should display the remarks on a label. Use select case statement. Attach the program to a
command button. (7 marks)
Table 1
2920/205
3
July 2019
(c) The following is an error statement in a Visual Basic program. Use it to answer the questions
that follow:
Explain the function of the part labelled (i), (ii) and (iii) when used in a program statement.
(6 marks)
(d) (i) Determine the output from each of the following Visual Basic logical statements. (2 marks)
I If (expression 1) is true and (expression 2) is true;
II If (expression 1) is false or (expression 2) is true.
(ii) Write a program in Visual Basic that accepts the number x through the use of a textbox. If
the value of the expression x3 – x is greater or equals to 100, the program displays the
message “A big number!” on a label, otherwise output “A small number!”. (5
marks)
3. (a) Outline three activities that can be done on the project window in a Visual Basic Program.
(3 marks)
(b) Explain each of the following terms as used in variable declarations in a Visual Basic
Program. (6 marks)
(i) lifetime;
(ii) scope;
(iii) datatype.
(c) Distinguish between variablename = InputBox (“message”) and
variablename = Val (InputBox (“message”)) Statement as used in Visual
Basic programming. (4 marks)
(d) (i) Write a Visual Basic statement that would display the value 40976 formatted to each of the
following:
I. Date;
II. Currency. (2 marks)
4
July 2019
(ii) The length of the hypotenuse of a right-angle triangle is given by the formula c=√ a2 +b 2
where a and b are the perpendicular sides and c is the hypotenuse.
Write a program in Visual Basic that would accept the values a and b through the use of a
text box, compute the hypotenuse and display the results on a message box. (5 marks)
4. (a) Outline four methods of a list box as used in a Visual Basic program. (4 marks)
(b) Distinguish between on error go to 0 and on error go to – 1 statements in a Visual Basic
program. (4 marks)
(c) Explain the reasons for applying each of the following in an array in a Visual Basic program.
(6 marks)
(i) Control array;
(ii) Array bound;
(iii) Redim statement
(d) Write a program in Visual Basic with a label and text box named label 1 and Text1
respectively that uses a procedure to perform the following sequence of events when the
command button is clicked. Use with statements. (6 marks)
Textbox 1 is disabled
The background color of TextBox 1 becomes yellow;
Label 1 becomes visible;
Text on the label to have a blue color;
The font of text on the label to be bold.
5. (a) State the correct data type in Visual Basic programming for each of the following description
of statements.
(b) Ali a programmer created a Visual Basic program and ran it in his computer, he observed the
error” object not found” displayed on the screen. Explain two causes of this error. (4 marks)
5
2920/205
July 2019
(c) Explain each of the following as used in data structures: (6 marks)
(i) bubble sort;
(ii) binary search;
(iii) tree transversal
(d) Write a program in Visual Basic that would display the following pattern on a picturebox;
(6 marks)
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
6. (a) Outline three ways in which a project can be started in a Visual Basic program window.
(3 marks)
(b) Distinguish between adcmdtext and adcmdtable values as used ADO Data controls in a Visual
Basic Program. (4 marks)
(c) Figure 1 shows a dialog box used to prompt one to choose one of the three mechanisms for
connecting to a database.
Explain the circumstances that may lead one to use each of the options labelled (i), (ii) and (iii)
(6 marks)
2920/205 Turn over
6
July 2019
7
(d) Write a program in Visual Basic that would compute the summation of integers from 20 to 50
and display the results on a label. Use a For loop statement. (7
marks)
7. (a) Outline four events of an ADO Data control as used in Visual Basic Programming. (4 marks)
(b) Distinguish between public and local array declaration in a Visual Basic program. (4 marks)
(c) Describe the two properties to be set on a textbox in order to display data from a database in
Visual Basic. (4 marks)
(d) Write a program in Visual Basic that accepts a name and a score of six students in a test
through the use of an inputbox (). The program should then display the names scores and the
average scores on a picture box. Attach the code to a command button. (8 marks)
8. (a) Distinguish between a listbox and a combobox as used in Visual Basic. (4 marks)
(b) Write an algorithm to implement each of the following in a stack data structures: (6 marks)
(i) Check if it is full;
(ii) Add an element.
(c) Eric a programmer intends to create an application in Visual Basic program and would like to
connect a database to bound controls on the forms. Describe two controls that would help him
achieve his goal. (4 marks)
(d) Write a program in Visual Basic that on command button click, the program add the values
from three text boxes into a database table with the fields named, AdNo, StudName and StudClass
respectively using the ADO command. The program should then update the database and display
the message “data added” on a messagebox (). (6 marks)
2920/205
8
July 2019