0% found this document useful (0 votes)
11 views4 pages

Visual Basic Programming Exam Guide

This document outlines the examination paper for the Visual Basic Programming course at Machakos University for the 2021/2022 academic year. It includes instructions, a series of questions covering various aspects of Visual Basic programming, such as components of the Integrated Development Environment, variable declarations, user-defined data types, and error handling. The exam consists of five questions, requiring students to answer question one and any two additional questions.

Uploaded by

kengashkg7
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views4 pages

Visual Basic Programming Exam Guide

This document outlines the examination paper for the Visual Basic Programming course at Machakos University for the 2021/2022 academic year. It includes instructions, a series of questions covering various aspects of Visual Basic programming, such as components of the Integrated Development Environment, variable declarations, user-defined data types, and error handling. The exam consists of five questions, requiring students to answer question one and any two additional questions.

Uploaded by

kengashkg7
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MACHAKOS UNIVERSITY

University Examinations for 2021/2022

SCHOOL OF ENGINEERING AND TECHNOLOGY


DEPARTMENT OF COMPUTING AND INFORMATION TECHNOLOGY
FIRST YEAR SPECIAL / SUPPLEMENTARY EXAMINATIONS FOR
BACHELOR OF SCIENCE (INFORMATION TECHNOLOGY)
SIT104: VISUAL BASIC PROGRAMMING
DATE: 29/8/2022 TIME: 8.30-10.30 AM
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. ToolBox;
II. Form designer. (4 marks)
(ii) John, a program prefers to use Visual Basic programming language to create
applications. Outline three features of Visual Basic language that could have
led to this preference. (3 marks)
(b) (i) Describe each of the following Visual Basic objects:
I. Picture Box;
II. Vertical ScrollBar;
III. Shape. (6 marks)
(ii) Distinguish between explicit and implicit variable declaration as used in
Visual Basic programming. (4 marks)

(c) (i) State the prefix associated with each of the following Visual Basic controls:
I. CommandButton;
II. TextBox;
III. Label;
IV. ListBox. (2 marks)

Examination Irregularity is punishable by expulsion Page 1 of 4


(ii) Describe each of the following types of procedures:
I. Event procedure;
II. Property procedure. (4 marks)
(d) Write a Visual Basic program that would prompt a user to enter either a rectangle or
a circle. The program then prompts the user to enter the dimensions of the selected
figure and then computes and outputs the area using a function. All the entries are
through input box and the output is through a message box. (7 marks)
2. (a) (i) State whether or not each of the following terms are valid Visual Basic
variables:
II. County//
III. Student_Name
IV. String (4 marks)
(ii) Assuming Visual Basic programming language, state the order of execution
of the following statement.
Y = X ^3 + Y – A * (B / C) (2 marks)
(b) (i) Write the output generated by each of the following Visual Basic string
functions.
I. Len(Machakos University)
II. Trim( Valentine ) (2 marks)
(ii) Write the output generated when the following Visual Basic statement is
executed:
A = sgr(B) given that B = 16 (2 marks)

(c) Distinguish between local and static variables as used in Visual Basic programs.
(4 marks)
(d) Write a Visual Basic program that will generate the following output on a form.

The value of a is: 10


The value of a is: 15
The value of a is: 20 (6 marks)
3. (a) (i) Explain the term user defined data type as used in programming. (2 marks)
(ii) Creat a data type that would be able to store a product details that include
productID, productName, quantity and price in a visual basic program.
(4 marks)

Examination Irregularity is punishable by expulsion Page 2 of 4


(b) (i) Explain two methods used to connect a Visual Basic program to a database.
(4 marks)

(ii) Describe two components that are necessary for the creation of a Visual
Basic report. (4 marks)

(c) A program prompts a user to enter the number of students in a lecture room. The
program then prompts a student to the fee paid in the semester. A message “You
have cleared” is displayed when a student has paid all the fee, otherwise a message
“You have not cleared” is displayed.
Draw a flow chart that could be used to implement the program logic. (6 marks)
4. (a) (i) Outline three data types other than integer used in Visual Basic programming
language. (3 marks)
(ii) Study the following Visual Basic program code and then answer the question
that follows:
Private Sub cmdResults_Click()
Dim Num1, Num2, Num3, Num4 As Integer
Num1 = (InputBox(“Enter an Integer”))
Num2 = (InputBox(“Enter an Integer”))
Num3= Num1/Num2
Num4 = Num1 mod Num2
Print Num3
Print Num4
End Sub

State the output generated given that Num1 = 10 and Num = 5 (4 marks)
(b) (i) Construct a truth table for the AND logical operator. (4 marks)
(ii) Represent the while..loop in a flow chart segment. (3 marks)
(c) Mashinani University allows applicants to apply for courses online. The application
form consists of a label, a text box, option buttons, combobox and a command
button.
The label is placed next to the text box to identify it, the applicant types his/her name
in the textbox, selects the appropriate option for the gender and then selects a course
through the combo box. The information is then submitted by clicking the command
button.

Examination Irregularity is punishable by expulsion Page 3 of 4


Assuming Visual Basic programming language environment, sketch the interface
that could be used to implement this logic. (6 marks)
5. (a) Sketch the output generated when the following Visual Basic statement is executed.
(3 marks)
RegNo = InputBox ("Enter the registration number", “Reg Number”,
xxxx)
(b) Write a Visual Basic program that would generate the following output on a form.
50 60 70
50 60
50
Attach the code to a command button. (4 marks)
(c) Distinguish between do while.. loop and do.. loop while iteration statements as used
in Visual Basic programs. (4 marks)
(d) (i) Outline three functions used to handle errors in Visual Basic programming.
(3 marks)
(ii) Explain three types of errors that could be encountered in programming.
(6 marks)

Examination Irregularity is punishable by expulsion Page 4 of 4

Common questions

Powered by AI

Visual Basic string functions like 'Len' can be used to find the length of a string, and 'Trim' removes leading or trailing spaces. For instance, Len('Machakos University') returns 18, and Trim(' Valentine ') returns 'Valentine', demonstrating these manipulations .

Creating a report in Visual Basic typically requires components such as a Data Report, which is an object that forms the core structure of the report, and a Data Environment, which acts as a source for accessing and manipulating database information, providing an interface for designing how data appears .

A Visual Basic program can connect to a database using methods such as ADO (ActiveX Data Objects) and DAO (Data Access Objects). ADO provides a high-level programming model that is suitable for a variety of sources, while DAO is used mainly to access databases like Microsoft Access directly within the Visual Basic environment .

Three types of errors in Visual Basic programming include syntax errors, which occur when the code violates the language rules; runtime errors, which happen during program execution when the environment cannot complete an operation; and logic errors, which do not stop the program but result in incorrect output due to incorrect logic .

When designing a user interface in Visual Basic, considerations include usability, clarity, and intuitiveness, ensuring labels clearly define inputs, options are easily selectable, and the layout guides the user effectively through tasks. An example is an online application form interface with labels for text boxes, selection buttons for gender, a combobox for course selection, and a command button to submit the application .

The logic flow of the program starts with prompting the user to enter the number of students and the fee amount paid. It then checks if the fee matches the required amount. If it does, the message 'You have cleared' is displayed; otherwise, 'You have not cleared' appears. This logic can be depicted with a flowchart starting from initialization, input, condition checking, corresponding message display, and finally termination .

Visual Basic is preferred due to its ease of use, extensive library of built-in functions, and integrated development environment (IDE) that simplifies application development by providing a user-friendly interface. It allows programmers to drag and drop controls and easily view code behind those controls .

Explicit variable declaration in Visual Basic requires the programmer to declare a variable with a specified type before it is used, using a 'Dim', 'Private', 'Public', or 'Static' statement. In contrast, implicit declaration is when variables are used without being declared beforehand, which might lead to errors and inefficient memory usage .

A truth table for the AND operator is constructed with two inputs, which output true only when both inputs are true. In Visual Basic, this is used in decision-making structures to ascertain conditions where multiple criteria need to be satisfied, such as in 'If' statements that control the flow of a program based on compound conditions .

Static variables in Visual Basic retain their value even after the procedure in which they are declared has finished execution, allowing persistent data storage throughout the application’s run time. In contrast, local variables lose their value once the procedure exits, which limits their scope and lifetime to the procedure itself .

You might also like