CSCI 112
Fall 2026 - Assignment 8
Submit deadline: 13:00, 26 November 2026, Thursday
Objectives:
- Get proficient with using loop statements
- Practice some typical loop applications
- Learn to develop a VBA program with multiple procedures
References:
Problem Description
An instructor (like me) keeps the assignment and exam marks of her
students in an Excel file.
A sample student mark records can be viewed in
A8-input.xlsx.
In the file, you can see that Row 5 stores the assignment/exam names,
Row 6 stores the maximum mark you can get in the corresponding
assignment/quiz/exam, and Row 7 stores the percentage of how much
the corresponding assignment/quiz/exam contributes to the final mark.
To calculate a student's final mark, first we calculate the
individual contribution of each assignment/exam as
(this student's mark in this assignment/exam) multiplies
(the contribution percentage of this assignment/exam) then
divided by (the maximum mark of this assignment/exam),
then we sum the individual contributions of all assignment/exams
together, the result would be this student's final mark.
In calculating the student's final mark, we need to keep the decimal
part of each contribution to at least 2 digits after the decimal.
However, before we can translate the final mark to its corresponding
letter grade,
the final mark needs to be rounded to an integer number. The VBA
function that performs the rounding is:
Round(number, number_of_digits_after_decimal)
The first number in the brackets should be the number to
be rounded and the second number in the brackets should
be an integer number indicating how many digits after the
decimal point should be kept. The returned value from function
Round would be the rounded result.
The grade scale used to translate the numerical marks to
their corresponding letter grades
is shown in the range from A1 to L3 of the worksheet.
Your tasks:
- Download the sample input file.
- Open the file you just downloaded and you should see
the information described in the "Problem Description", and
a class list of students and their assignment/exam mark records
starting from row 9. Note that the list of students are
just samples to show the data format. There might be more
or fewer students in the actual class.
- Design a userform with at least a textbox (and its
associated prompt label),
two command buttons called "Display Info" and "Clear Form"
respectively, and a result label.
The textbox allows the user to enter a student's name,
and the result label is used to display the grade information of
the given student.
- Write a VBA program to handle the click event of the command button
captioned "Display Info" by performing the following tasks:
- Find the student (Extra requirement: this sub-task
must be done by a separate procedure);
- If there isn't such a student in
the class, use the pre-defined label to display
a proper error message;
- If the student can be found in the class, calculate their
final numerical mark (Extra requirement: the calculation must
be done in a separate procedure), then convert their
numerical mark to its corresponding letter grade (Extra
requirement: the conversion must be done in a separate
procedure);
- Display the student's information using the pre-defined
lable. The displayed information should at least
include the student's final numerical mark before rounding
and their letter grade, and preferrably also include
their marks of every individual assignment/quiz/exam.
- Write a VBA program to handle the click event of the command button
captioned "Clear Form" by clearing the content in the pre-defined
information displaying label and the textbox.
- Save your work to a Macro- enabled Excel file
and give the solution file a meaningful name.
Your overall program must design and implement 3 separate
procedures to handle the search of the student, the calculation
of the final numerical mark of a selected student,
and the conversion of the numerical mark to its equivalent
letter grade. Then the main subroutine that handles the
command button click must call/use these 3 procedures
to perform the "Display Info" task.
Before submitting your assignment, you need to check at least
the following things:
- Did you divide the overall task into sub-tasks as required
in the specification? If there is no design, implementation
and use of the assisting procedures in your program, you
will receive at most half of the assignment marks.
- Is your userform interface user-friendly?
- Is your program logically correct and easy to understand?
- Did you handle exceptions properly?
- Did you properly and consistently indent your source code?
- Did you place "Option Explicit" at the beginning of your program?
- Did you give meaningful names to ALL your constants, variables
and control objects?
- Did you test your program thoroughly using different combinations
of data, such as the first student, the last student, a student
in the middle of the class, and a non-existent student?
How to submit:
To submit your assignment,
login to your VIU Learn account, find the CSCI 112 course page,
click on the "Assessment" drop-down menu, click
on the "Assignments" item, then click on the folder named "A8".
Then you can click on the "Add a File" button to browse and upload your
(macro-enabled) solution file.
If you have difficulties to submit through the VIU Learn,
please email me to let me know and attach your solution file
with your email.
Last update: November 10, 2026