CSC 231 Lecture Notes
CSC 231 Lecture Notes
Object-Oriented Programming (OOP) is a programming method that organizes code into objects and classes. It
is based on real-world entities, making software development more structured, reusable, and manageable.
Code Reusability – You can use existing classes and objects in different programs, reducing code
duplication.
Data Security – Encapsulation ensures that important data is protected from unauthorized access.
Scalability and Maintainability – Code is easier to update and expand without breaking other parts.
Better Organization – Programs are structured using logical relationships, making them easier to
understand.
Improved Debugging – Since objects are independent, errors can be located and fixed easily.
Visual Basic (VB) supports all the core principles of OOP. The four key concepts in OOP are:
A class is a blueprint or template used to create objects. It defines properties (variables) and methods (functions)
that objects will have.
An object is an instance of a class. Think of a class as a recipe and an object as the actual dish made from that
recipe.
vb
Public Class Student
Public Name As String
Public Age As Integer
Explanation:
2.2. Encpsulation
Encapsulation means hiding the internal details of a class while allowing controlled access through methods.
This helps protect data from accidental modification.
Explanation:
The balance variable is private, meaning it cannot be accessed directly from outside the class.
The method Deposit(amount As Double) allows controlled modification of balance.
The method GetBalance() allows controlled reading of the balance.
vb
CopyEdit
Dim myAccount As New BankAccount()
myAccount.Deposit(500)
Console.WriteLine("Balance: " & myAccount.GetBalance()) ' Output: Balance: 500
Explanation:
2.3. Inheritance
Inheritance allows a child class to inherit properties and methods from a parent class. This avoids repeating code
and enables code reuse.
Explanation:
Explanation:
myDog is an object of Dog, but it can use the Speak() method from Animal.
2.4. Polymorphism
Polymorphism means "many forms"—a method can have different implementations in different classes. This is
useful when a child class overrides a method from the parent class.
Explanation:
Using Polymorphism
Explanation:
Although pet is still based on Animal, it calls the overridden Speak() from Dog instead.
Summary
OOP in Visual Basic provides a structured, reusable, and secure way to develop software. The key concepts are:
By understanding and applying these concepts, programmers can create efficient, scalable, and maintainable
applications in Visual Basic (VB).
An electronic spreadsheet is a digital tool that allows users to organize, store, manipulate, and analyze numerical
and textual data using a structured grid of rows and columns. It is widely used in businesses, education,
research, finance, and personal data management due to its ability to automate calculations and visualize data
efficiently. In earlier times, businesses and accountants used paper-based spreadsheets to record financial
transactions. However, with the advancement of technology, electronic spreadsheets have replaced manual
record-keeping, offering greater accuracy, speed, and convenience.
The Microsoft Excel is a spreadsheet package included in the Microsoft Office . The Microsoft
Office suite includes apps that give us the ability to create and manage every type of file we need to
work effectively at home, business, or school. The apps include Microsoft Word, Excel, Outlook,
PowerPoint, Access, OneNote, and Publisher. They are designed as an integrated package.
In Microsoft Excel the data we enter, whether it consists of numbers, text, or formulas, is stored in
a file known as a workbook. Workbooks are just like huge electronic books with pages (or sheets)
that have been organised into columns and rows. Before using Excel it is helpful to know what the
various parts and elements that make up a workbook are.
o A worksheet (or page) in a workbook contains 16,384 columns that are labelled using letters
of the alphabet. The first column in a worksheet is labelled column A, while the last is labelled XFD
o A worksheet (or page) in a workbook contains 1,048,576 rows that are labelled using
numbers from 1 to 1,048,576.
o The area of intersection of rows and columns are called cells. We enter our data into these
cells. Each cell in a worksheet can hold up to 32,767 characters – although it would be unrealistic
to ever push it this far. Cells are referred to by their column and row labels. For example, the cell
C11 (intersection of Column C and Row 11)– this reference is known as the cell
address and is most important as it is frequently used in commands and formulas.
o When we start typing something, we want it to appear somewhere in the
worksheet. As a consequence when the Status Bar shows Ready mode, at least one
cell in the worksheet will be highlighted – this is known as the active cell. In a case
if, the active cell is cell A1 – notice that the column label and the row label also
appears coloured to indicate the active cell. We can have more than one active cell –
known as a range
o A workbook is made up of pages known as worksheets. We can have as many
sheets in a workbook as our computer resources can accommodate. As a default, a
new blank workbook normally has 3 worksheets labelled Sheet1, Sheet2, and Sheet3.
o The Insert Worksheet button will insert another worksheet into the current workbook.
Click on the New Sheet icon to the right of the worksheet tabs
2. Copying a worksheet
Just as we can copy the contents of cells and ranges within a worksheet, we can
duplicate worksheets within a workbook. This technique is ideal for replicating
layouts. For example, if we have a budget workbook that contains data for several
departments, we can create a worksheet for the first department and then copy it to
create identical worksheets for other departments.
To copy a worksheet:
3. Renaming a worksheet
By default, Excel names worksheets as Sheet1, Sheet2, Sheet3, etc. These names are
fine if we are not planning to share the workbook, but changing these to something
more relevant makes it much easier to understand the purpose of a worksheet. We
can also adjust the horizontal scroll bar to make room for longer, more meaningful
worksheet names.
To rename a worksheet:
6. Grouping worksheets
Worksheet grouping enables us to make the same change at once to all selected
worksheets. This feature is useful in situations where our worksheets have identical
layouts or text. For example, if we want to format the heading for multiple
worksheets, we simply group the worksheets, make a change to one worksheet and
the other worksheets will reflect the change also.
i. Row
A row is a horizontal arrangement of cells in a spreadsheet, identified by numbers (e.g.,
1, 2, 3…).
ii. Column
A column is a vertical arrangement of cells in a spreadsheet, identified by letters (e.g., A,
B, C…).
iii. Cell
A cell is the intersection of a row and a column, identified by a cell reference (e.g., A1,
B5). It is the basic unit where data is entered.
iv. Range
A range is a group of two or more selected cells in a spreadsheet. It can be contiguous
(e.g., A1:A5) or non-contiguous (e.g., A1:A5, C1:C5).
v. Value
A value is a numerical or textual entry in a cell. It can be a number, date, time, or text.
vi. Function
A function is a predefined formula in a spreadsheet that performs a specific calculation
(e.g., SUM(A1:A5), AVERAGE(B1:B10)).
vii. Formula
A formula is a user-defined expression that performs calculations using values, cell
references, and functions. It starts with an equal sign (=) (e.g., =A1+B1, =SUM(C1:C10)).
Field Application
Business Financial analysis, payroll processing, budgeting
Education Student grading, attendance records
Research Data collection, statistical analysis
Engineering Simulation models, complex calculations
Healthcare Patient records, drug inventory
Banking Loan calculations, interest computation
Electronic spreadsheets are essential tools in modern computing for managing, analyzing, and
presenting data. They provide:
User-friendly interfaces
Powerful computational abilities
Advanced visualization tools
Automation for repetitive tasks
By mastering spreadsheets, users can improve efficiency in data management and decision-
making processes.