MACHAKOS UNIVERSITY
University Examinations for 2016/2017
SCHOOL OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF COMPUTING AND INFORMATION TECHNOLOGY
FIRST YEAR SECOND SEMESTER EXAMINATION FOR DEGREE IN
BACHELOR OF SCIENCE IN INFORMATION TECHNOLOGY
SIT 104: VISUAL BASIC PROGRAMMING
DATE: 6/6/2017 TIME: 2:00 – 4:00 PM
INSTRUCTIONS
This paper consists of FIVE questions
Answer question one and other two questions in this paper
1. (a) (i) Describe each of the following components of the Visual Basic Integrated
Development Environment.
I. Properties Window;
II. Object browser.
(4 marks)
(ii) Outline three circumstances that could lead to the use of Visual Basic in the
development of an application. (3 marks)
(b) (i) Describe each of the following Visual Basic objects:
I. ComboBox;
II. ListBox;
III. OptionButton. (6 marks)
(ii) Distinguish between event and method as used in Visual Basic programming.
(4 marks)
(c) (i) State the prefix associated with each of the following Visual Basic controls:
I. Timer;
II. CheckBox;
III. Shape;
IV. Form. (2 marks)
Examination Irregularity is punishable by expulsion Page 1 of 4
(ii) Describe each of the following types of modules:
I. Form Module;
II. Class Module. (4 marks)
(d) Write a Visual Basic program that would prompt a user to enter the units of temperature
(either Celsius or Fahrenheit) through the use of an input box. The program then prompts the
user to key in temperature in the unit entered, converts the temperature to the alternative unit
and displays the results through a message box. Use functions to convert. Attach the code to
a command button.
Hint: Celsius = 5/9 * Fahrenheit – 32, Fahrenheit = 9/5* Celsius + 32.
(7 marks)
2. (a) (i) Outline four rules of naming variables in Visual Basic language. (4 marks)
(ii) Assuming Visual Basic programming language, state the order of execution of the
following statement.
Z = exp X + Y – A * (B / C) (2 marks)
(b) (i) Write the output generated by each of the following Visual Basic string functions.
I. Upper(School of Computing)
II. Ltrim( Standard ) (2 marks)
(ii) Write the output generated when the following Visual Basic statement is executed:
A + B = B + C, Given that A = 10, B = 5, C = 8
(2 marks)
(c) Distinguish between debug and run Visual Basic commands. (4 marks)
(d) Write a Visual Basic program that will compute the average of integers between 100 and 200
and output the result on a form. Use do.. loop. Attach the code to a command button.
(6 marks)
3. (a) Explain each of the following methods of connecting a Visual Basic application to a
database.
(i) ADO-DC;
(ii) ActiveX control. (4 marks)
(b) (i) With the aid of a sketch in each case, describe two types of reports that could be
generated in a Visual Basic application. (4 marks)
(ii) Describe two functions that could be inserted in Visual Basic report. (2 marks)
(c) John, a programmer would like to create a Visual Basic application for capturing amount of
milk supplied to a cooperative society by fifty farmers daily. Using a flow chart design the
program for John. (6 marks)
Examination Irregularity is punishable by expulsion Page 2 of 4
(d) Study the following Visual Basic program code and then answer the questions that follow:
Private Sub cmdAdd_Click()
Dim Num As Integer
Num = (InputBox(“Enter an Integer”))
Num = Num + 10
Num = (Num - 3) mod 4
picbox. Print Num
End Sub
(i) Interpret the program.
(ii) State the output generated if the input value is 10. (4 marks)
4. (a) Outline three data types used in Visual Basic programming language. (3 marks)
(b) (i) Explain two classes of operators used in Visual Basic programming language, citing
two examples in each case. (5 marks)
(ii) Outline four elements of for control structure. (4 marks)
(c) Outline the use of each of the following inbuilt functions:
(i) DateAdd ( )
(ii) Year ( )
(iii) DateDiff ( ) (3 marks)
(d) The national government allocates bursary to university students annually. A student needs to
apply by filling a form online. The form consists of a textbox to enter the student’s
registration number, a combo box to select the university, a picture box to upload a photo and
option buttons to select gender. The form is submitted by clicking a button.
Sketch a Visual Basic language interface that could be used to implement this logic.
(5 marks)
5. (a) Sketch the output generated when the following Visual Basic statement is executed.
(4 marks)
MsgBox "The current date and time of the system is", “VbOKCancel” & Now
(b) Write a Visual Basic program that would generate the following output on a form.
7 8 9
7 8
7
Attach the code to a command button. (4 marks)
(c) Distinguish between GotFocus and DropDown properties of a combobox. (4 marks)
Examination Irregularity is punishable by expulsion Page 3 of 4
(d) Table 2 shows the grade scored by a candidate at KCSE and a corresponding area of study
the candidate may be admitted into. Use it to answer the question that follows.
Grade Course
A Engineering
B Medicine
C Law
D Science
Arts
Table 3
Write a Visual Basic program that would prompt a user to enter the grade scored by a
candidate through an input box. The program then outputs the corresponding area of study
through a message box. Use the select control structure and attach the code to a command
button. (8 marks)
Examination Irregularity is punishable by expulsion Page 4 of 4