Chapter 3
27/09/2015
Bale, Robe Ethiopia
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 1
3.1. Language Fundamentals
VISUAL BASIC OBJECTS
‒ Visual Basic programs display a Windows style screen (called a form) with boxes into which users type (and edit) information
and buttons that they click to initiate actions. The boxes and buttons are referred to as controls.
‒ Forms and controls are called objects.
‒ Visual Basic programs consist of three parts—interface, values of properties, and code.
Comments
‒ As with any programming language, commenting your code is up to you.
‒ Comment statements are neither executed nor processed by VB .NET. As a result, they do not take up any room in your
compiled code. There are two ways to indicate a comment
‒ The usual way is with a single quote as in the line in bold:
1. Sub MainO
2. Console.WriteLine("Hello world")
3. 'throw away the return value of ReadLine
4. Console. ReadLine()
5. End Sub
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 2
3.1. Language Fundamentals…1
Statements in VB .NET
‒ Nonetheless, the VS .NET IDE will try to impose its own conventions on your VB .NET programs. It
capitalizes the first letter of keywords and often adds extra spaces for readability. For example, no matter
how you capitalize End SUB, you will end up with End Sub.
‒ Methods in VB .NET use the capitalization that is usually called Pascal casing (initial caps).
‒ The alternative form, writeLine, which is not commonly used in .NET for methods, is called camel
casing. (It is called such because names written using camel casing tend to have a "hump" in the middle,
just like a camel.)
‒ Next, statements in VB .NET rarely-if ever-use line numbers, although line numbers are possible, and
each statement generally occurs on its own line.
‒ Lines can be extended to the next line by using the underscore character U as long as the underscore is
preceded by one or more spaces. Thus, unless a line ends with an underscore, pressing the Enter key
indicates the end of a line.
‒ (There is no semicolon statement separator, as in some other languages in the VS .NET family.)
‒ You can combine statements on one line by placing a colon (:) between them, but this is rarely done.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 3
3.1. Language Fundamentals…2
Conversion between Values of Different Types
‒ When it is acceptable to convert the contents of a variable from one type to another, you do
the cast with a conversion function such as the CBool.
Table 3-1. Conversion (Cast) Functions
CONVERSION FUNCTION WHAT IT DOES
Cbool Makes an expression a Boolean.
Cbyte Makes an expression a byte.
Cint a numeric expression an integer by rounding.
CLng Makes a numeric expression a long integer by rounding.
CSng Makes a numeric expression single precision.
Cdate Makes a date expression a date.
CDbl Makes a numeric expression double precision.
Cdec Makes a numeric expression of the currency type.
CStr Makes any expression a string.
Cchar Converts the first character in a string to a Char.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 4
3.1. Language Fundamentals…3
Conversion between Values of Different Types
For example, Compute sum of a two number obtained from keyboard and
display it at third text box.
1.'Declare a variable for the first number
2. Dim x,y,z As Integer
3. x = CInt(TextBox1.Text)
4.'into an integer And assign it to the second variable
5. y = CInt(TextBox2.Text)
6. z = x + y
7. 'Convert the third variable (which Is an integer) to
text.
8. TextBox3.Text = CStr(z)
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 5
3.1. Language Fundamentals…4
The Object Type (and the Death of Variants)
‒ In VB6, the variant data type holds any type of data, is prone to misuse, and is a source of subtle bugs.
‒ In VB .NET, every data type is actually a special case of the Object data type-even numeric types such as
Integer-making it tempting to think of the Object type as the VB .NET equivalent of variants.
Example:
Dim a As Object
a=5
Dim b As Object
b = 2.123123
If (a <= b) Then
MsgBox("Y, b/c a<=b")
Else
MsgBox("N, b/c a>b")
End If
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 6
3.1. Language Fundamentals…5
Strings
‒ String variables hold groups of Unicode characters. A string can contain up
to about 2 billion (2 ^31) Unicode characters.
‒ As you have seen, you now assign a string to a variable using double quotes:
Example: assign a string to a variable using double quotes
Dim message as String
message = "Help"
‒ the simplest way to concatenate (join them together) is to use the &.
‒ The older + will also work, but can lead to major problems
‒ The older way to identify string variables (which are occasionally still used
for temporary variables) is to use a dollar sign ($) at the end of the variable
name: aStringVariable$.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 7
3.2. Classes and Objects
‒ Noun: A word used to denote or name a person, place, thing, quality, or
act.
‒ Verb: That part of speech that expresses existence, action, or occurrence.
‒ Adjective: Any of a class of words used to modify a noun or other
substantive by limiting, qualifying, or specifying.
The American Heritage Dictionary of the English Language
‒ “A good rule of thumb for object-oriented programming is that classes are
the nouns in your analysis of the problem. The methods in your object
correspond to verbs that the noun does. The properties are the adjectives
that describe the noun.”
Gary Cornell & David Jezak
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 8
3.2. Classes and Objects…1
‒ Visual Basic is an object-oriented programming language , which is a language that allows the programmer
to use objects in an application’s interface and also in its code.
‒ In object-oriented programming, or OOP , an object is anything that can be seen, touched, or used.
‒ In other words, an object is nearly any thing.
‒ The objects used in an object-oriented program can take on many different forms. The text boxes, list
boxes, and buttons that appear in an application’s interface are objects.
‒ The variables and named constants declared in an application’s code are also objects.
‒ An object can also represent something found in real life, such as a file on a disk.
‒ Every object in an object-oriented program is created from a class , which is a pattern that the computer
uses to create the object. The class contains the instructions that tell the computer how the object should
look and behave.
‒ An object created from a class is called an instance of the class and is said to be instantiated from the
class. A button control, for example, is an instance of the Button class and is instantiated when you drag the
Button tool from the toolbox to the form.
‒ A String variable, on the other hand, is an instance of the String class and is instantiated the first time you
refer to the variable in code. Keep in mind that the class itself is not an object; only an instance of a class is
an object.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 9
3.2. Classes and Objects…2
‒ Every object has a set of attributes , which are the characteristics that describe the
object. Attributes are also called properties. Included in the attributes of buttons and
text boxes are the Name and Text properties. String variables, on the other hand, have a
Length property.
‒ Every object also has a set of behaviors , which include both methods and events.
‒ Methods are the operations (actions) that the object is capable of performing. For
example, a button can use its Focus method to send the focus to itself. Similarly, a
String variable can use its ToUpper method to temporarily convert its contents to
uppercase.
‒ Events , on the other hand, are the actions to which an object can respond. A button’s
Click event, for instance, allows the button to respond to a mouse click.
‒ A class contains—or, in OOP terms, it encapsulates —all of the attributes and behaviors
of the object it instantiates. The term encapsulate means to enclose in a capsule. In the
context of OOP, the “capsule” is a class.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 10
3.2. Classes and Objects…3
‒ An object is an encapsulation of data and procedures that act on the data.
‒ The only thing of concern to a programmer using an object is the tasks that the object can perform and the parameters
used by these tasks. The details of the data structures and procedures are hidden within the object.
‒ Two types of objects will be of concern to us,
control objects and code objects. Examples of control objects are text boxes, picture boxes, command
buttons and all the other controls that can be created from the Visual Basic toolbox.
Code objects are specific instances of user-defined types that are defined similarly to record types in a
separate module. A code object is a specific instance of a user-defined type, called a class, which is
defined similarly to a structure, but in a separate class block of the form
‒ Class ClassName
‒ statements
‒ End Class
‒ An object, which is an instance of a class, can be created in a program with a pair of statements of the form
Dim objectName As className ‘In General Declarations section
objectName = New className (argl, arg2, ... ) ‘In procedure
‒ Both types of objects have properties and respond to methods.
‒ The main differences are that control objects are predefined and have physical manifestations, whereas code objects
must be created by the programmer and exist solely in a portion of memory.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 11
3.2. Classes and Objects…4
Example of how to create a class.
The following example shows you how to create a class that can calculate your BMI (Body Mass Index).
Step: to create a class,
‒ start Visual Basic 2019/2022 as usual and choose Windows Applications. In the Visual Basic 2019/2022 IDE, click on
Project on the menu bar and select Add Class, as shown in Figure 1.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 12
3.2. Classes and Objects…5
Example: The following program shows you how to create a class that can calculate your BMI (Body Mass Index). ..1
Click on the Class item and the default class Class1.vb will appear as a new tab in a code window. Rename the class as
MyClass.vb. Rename the form as MyFirstClass.vb.
Now, in the MyClass.vb window, create a new class MyClass1 and enter the following code
1. Public Class MyClass1
2. Public Function BMI(ByVal height As Single, ByVal weight As Single)
3. BMI = Format((weight) / (height ^ 2), "0.00")
4. End Function
5. End Class
Now you have created a class (an object) called MyClass1 with a method known as BMI.
In order to use the BMI class, insert a button into the form and click on the button to enter the following code:
1. Private Sub BtnBMI_Click(sender As Object, e As EventArgs) Handles BtnBMI.Click
2. Dim MyObject As Object
3. Dim h, w As Single
4. MyObject = New MyClass1()
5. h = InputBox(“What is your height in meter”)
6. w = InputBox(“What is your weight in kg”)
7. MessageBox.Show(MyObject.BMI(h, w), "Your BMI")
8. End Sub
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 13
3.2. Classes and Objects…5
Example: The following program shows you how to create a class that can calculate your BMI (Body Mass Index). ..1
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 14
3.2. Classes and Objects…6
Example 2: The program in Example use a class named Student to calculate and display a student’s
semester grade. The information stored by an object of the type Student consists of a student’s name,
social security number, and grades on two exams (midterm and final). This data is stored in variables
declared with the statements
‒ Private m_name As String 'Name
‒ Private m_ssn As String 'Social security number
‒ Private m_midterm As Double 'Numerical grade on midterm exam
‒ Private m_final As Double 'Numerical grade on final exam
‒ The word Private guarantee that the variables cannot be accessed directly from outside the
object. In object-oriented programming terminology, these variables are called member
variables (or instance variables). We will follow the common convention of beg inning the name
of each member variable with the prefix "m_".
‒ Each of these variables is used to hold the value of a property. However, instead of being
accessed directly, each member variable is accessed indirectly with a property block. For
instance, the following property block consists of a Get property procedure to retrieve (or read )
the value of the Name property and a Set property procedure to assign (or write) the value of the
Name property:
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 15
3.2. Classes and Objects…7
Example 2: …1 accessed directly from code in the form's block. They can
be accessed only through Property procedures that allow
‒ Public Property Name() As String values to be checked and perhaps modified. Also, a
‒ Get Property procedure is able to take other steps
‒ Return m_name necessitated by a change in the value of a member
‒ End Get variable.
‒ Set(ByVal value As String) ‒ A property block needn't contain both Get and Set
‒ m_name = value property procedures . For instance, the block
‒ End Set ‒ Public WriteOnly Property Midterm() As Double
‒ End Property ‒ Set(ByVal value As Double)
‒ In a property block, additional code can be added’ after ‒ m_midterm = value
the Get and Set statements to validate the data before ‒ End Set
they are returned or stored. ‒ End Property
‒ The word Public allows the property to be accessed from ‒ specifies the Midterm property a "write only." This
outside the code for the Student class block. For instance, property could be specified to be "read only" with the
the Name property can be accessed by code in the form's block
class block. On the other hand, since the member
variables were declared as Private, they cannot be
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 16
3.2. Classes and Objects…8
Example 2: …2 final is from 200%
‒ Public ReadOnly Property Midterm() As Double ‒ grade = Math.Round(grade) 'Round the grade.
‒ Get ‒ Select Case grade
‒ Return m_midterm ‒ Case Is >= 90
‒ End Get ‒ Return "A"
‒ End Property ‒ Case Is >= 80
‒ Methods are constructed with Sub or Function ‒ Return "B"
procedures. A Function procedure is used when ‒ Case Is >= 70
the method returns a value; otherwise a Sub ‒ Return "C"
procedure will suffice.
‒ Case Is >= 60
‒ For instance, the method CalcSemGrade, which is ‒ Return "D"
used to calculate a student's semester grade, is
created as follows: ‒ Case Else
‒ Function CalcSemGrade() As String ‒ Return "F"
‒ Dim grade As Double ‒ End Select
‒ grade = (m_midterm + m_final) / 2 ‘Mid and ‒ End Function
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 17
3.2. Classes and Objects…9
Example 2: …3
An object of the type Student is declared in the fom's code with a pair of statements such a
Dim pupil As Student 'Declare pupil as an object of type Student
pupil = New Student () 'Create an instance of type Student
After these two statements are executed, properties and methods can be utilized with statements such as
pupil.Name = “Dereje Jacob"
txtBox.text = pupil.Name
‒ ListBox1.Items.Add("Name" & vbTab & "SSN" & vbTab & "Grade")
‒ ListBox1.Items.Add("===================")
‒ ListBox1.Items.Add(pupil.Name & vbTab & pupil.SSN & vbTab &
pupil.CalcSemGrade)
'Assign a value to m_name
'Display the student's name
'Display semester grade
The first statement calls the Set property procedure for the Name property, the second statement calls the Get
property procedure for the Name property, and the third statement calls the method CalcSemGrade.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 18
3.2. Classes and Objects…10
Example 3: …4
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 19
3.2. Classes and Objects…11
Example 3 The following program uses the class Student to calculate
and display a student' semester grade. The structure Person in
frmGrades is used by the btnDisplay_Click procedure to place
information into the DataGridView control.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 20
3.2. Classes and Objects…12
Example 3: …1
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 21
3.2. Classes and Objects…13
Example 3: …2 MessageBox . Show ( "Student Recorded." )
Public Class frrnGrades End Sub
Dim pupil As Student 'pupil is an object of class Student Private Sub btnDisplay_ Click( ... ) Handles btnDisplay.Click
Structure Person 'for use in btnDisplay Click Dim persons(O) As Person
Dim name As String persons( O) .name= pupil .Name
Dim socSecNum As String persons( O) .socSecNum = p u pil.SocSecNum
Dim semGrade As String persons( O) .semGrade = pupil . CalcSemGrade
End Structure Dim query = From someone In persons
Private Sub btnEnter_ Click( .. . ) Handles btnEnter.Click Select someone.name, someone .socSecNum, someone . semGrade
pupil = New Student () dgvGrades. DataSource = query.ToList
'Create an instance of Student. dgvGrades.CurrentCell = Nothing
'Read the values stored in the text boxes. dgv Grades.Columns( "name" ) .HeaderText = "Student Name"
pupil.Name = txtName.Text dgvGrades. Columns( "socSecNum" ) .HeaderText = "SSN"
pupil.SocSecNum = mtbSSN. Text dgvGrades .Columns( "semGrade" ) .HeaderText = "Grade"
pupil.Midterm = CDbl (txtMidterm.Text) End Sub
pupil.Final = CDbl (txtFinal.Text)
'Clear text boxes and list box
txtName. Clear ()
mtbSSN. Clear ()
txtMidterm.Clear()
txtFinal . Clear( )
'Notify user that grades for the student have been recorded.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 22
3.2. Classes and Objects…14
Example 3: …3 14.
15.
Public WriteOnly Property SSN() As String
Set(ByVal value As String)
‒ Private Sub btnQuit_Click(sender As Object, e As 16. m_ssn = value
EventArgs) Handles btnQuit.Click 17. End Set
‒ Me.Close() 18. End Property
‒ End Sub 19. Public WriteOnly Property Midterm() As Double
'frmGrades 20. Set(ByVal value As Double)
1. Public Class Student 21. m_midterm = value
2. Private m_name As String 'Name 22. End Set
3. Private m_ssn As String 'Social security number 23. End Property
4. Private m_midterm As Double 'Numerical grade on 24. 'Public ReadOnly Property Midterm() As Double
midterm exam 25. ' Get
5. Private m_final As Double 'Numerical grade on final 26. ' Return m_midterm
exam 27. ' End Get
6. Public Property Name() As String 28. 'End Property
7. Get 29. Public WriteOnly Property Final() As Double
8. Return m_name 30. Set(ByVal value As Double)
9. End Get 31. m_final = value
10. Set(ByVal value As String) 32. End Set
11. m_name = value 33. End Property
12. End Set
13. End Property
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 23
3.2. Classes and Objects…15
Example 3: …4
34. Function CalcSemGrade() As String
35. Dim grade As Double
36. grade = (m_midterm + m_final) / 2 ‘Mid and final is from 200%
37. grade = Math.Round(grade) 'Round the grade.
38. Select Case grade
39. Case Is >= 90
40. Return "A"
41. Case Is >= 80
42. Return "B"
43. Case Is >= 70
44. Return "C"
45. Case Is >= 60
46. Return "D"
47. Case Else
48. Return "F"
49. End Select
50. End Function
51. End Class 'Student
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 24
3.2. Classes and Objects…16
Example 3: …5
[Run, enter the data for a student (such as “Dereje Jacob", "111-22", “90", “80"),
‒ click on the Enter Information button to send the data to the obj ect, and click on the Display
Grade button to display the student's name, social security number, and semester grade.]
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 25
3.2. Classes and Objects…17
Example 3: …6 values of the variable. The general forms of the procedures are
In summary, the following six reps are u ed to create a class: Public Property PropertyName() As DataType
1. Identify a thing in your program that is to become an object. Get
2. Determine the properties and methods that you would like the (Possibly additional code)
object to have. (As a rule of thumb, properties should access data, Return variableName
and methods should perform operations.) End Get
3. A class will serve as a template for the object. The code for the Set (ByVal value As DataType)
class is placed in a class block of the form (Possibly additional code)
Class ClassName variableName
statements value
End Class End Set
4. For each of the properties in Step 2, declare a private member End Property
variable with a statement of the form In the Get or Set code, additional code can be added to prevent
Private variableName As DataType the object from storing or returning invalid or corrupted data. For
Member variables can be preceded with the keyword Public, example, an If block could be added to only allow valid social
which allows direct access to the member variables from the code security numbers, alerting the use r in the event of an invalid
in the form. However, this is considered poor programming number.
practice. By using Set property procedures to update the data, we 6. For each method in Step 2, create a Sub procedure or Function
can enforce procedure to carry out the task.
constraints and carry out validation.
5. For each of the member variables in Step 4, create a Property
block with G et and/or Set procedures to retrieve and assign
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 26
3.2. Classes and Objects…18
Example 3. The following modification of grade.
the program in Example 1 calculates If grade >= 60 Then
semester grades for students who have Return "Pass"
registered on a "Pass/Fail" bais. We create Else
a new class , named PFStudent, with the Return "Fail"
same member variables and property End If
procedures as the class Student. The only End Function
change needed in the class block occurs in The only change needed in the form's
the CalcSemGrade method. The new code code is to replace the two occurrences of
for this method is Student with PFStudent. When the
Function CalcSemGrade() As String program is run with the same input as in
Dim grade As Double Example 3, the output will be
grade = (m_midterm + m_ final) / 2 Dereje 111-111-1111 Pass
grade = Math.Round(grade) ‘Round the
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 27
3.2. Classes and Objects…19
Object Constructors
‒ Each class has a special method called a constructor that is always invoked when an object is
instantiated.
‒ The constructor takes zero or more arguments, and the code inside the procedure block performs
any tasks needed for initializing an object.
‒ It is often used to set default value for member variables and to create other objects associated
with this object. The first line of the constructor for a class has the form
Public Sub New(ByVal parl As DataTypel, ByVal par2 As DataType2, ... )
‒ The graphical program in Example 5 illustrates the use of a constructor to specify the size and
initial placement of a circle. This task involves pixels. To get a feel for how big a pixel is, the
initial size of the form when you create a new project is 300 pixels by 300 pixels. (Read how
graphic are created inside a picture box with the Graphic object gr = picBox.CreateGraphics.) In
Example 5, the statement
gr.DrawEllipse(Pens.Black, Xcoord, Ycoord, Diameter, Diameter)
draws a circle inside a picture box, where Xcoord andY coord are the distances (in pixels) of the
circle from the left side and top of the picture box.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 28
3.2. Classes and Objects…20
Object Constructors
Example 4 The following program contains a Circle object. The object keeps
track of the location and diameter of the circle. (The location is specified by
two numbers, called the coordinates, giving the distance from the left side
and top of the picture box. Distances and the diameter are measured in
pixels.) A Show method displays the circle, and a Move method adds 20
pixels to each coordinate of the circle. Initially, the (unseen) circle is located
at the upper left corner of the picture box and has a diameter of 40. The form
has a button captioned Move and Show Circle that invokes both methods.
Notice that the Xcoord, Ycoord, and Diameter properties, rather than the
member variables, appear in the methods.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 29
3.2. Classes and Objects…21
Object Constructors
Example 4…1
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 30
3.2. Classes and Objects…22
Object Constructors
Example 4…2
Public Class frmCircle
Dim round As New Circle ()
Private Sub btnMove_ Click( ... ) Handles btnMove.Click
round . Move(20)
round.Show(picCircle.CreateGraphics)
End Sub
Private Sub btnQuit_ Click( . . . ) Handles btnQuit.Click
Me .Close()
End Sub
End Class 'frmCircle
Class Circle
Private m_x As Integer 'Dist from left side of picture box to circle
Private m_ y As Integer 'Distance from top of picture box to the circle
Private m_d As Integer 'Diameter of circle
Public Sub New ()
'Set the initial location of the circle to the upperleft
'corner of the picture box, and set its diameter to 40.
Xcoord = 0
Ycoord = 0
Diameter 40
End Sub
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 31
3.2. Classes and Objects…23
Object Constructors Get
Example 4…3 Return m_d
Public Property Xcoord() As Integer End Get
Get Set (ByVal value As Integer)
Return m_ x m_d = value
End Get End Set
Set (ByVal value As Integer) End Property
m_x = value Sub Show(ByVal gr As Graphics)
End Set 'Draw a circle with the g1ven graphics context
End Property gr.DrawEllipse(Pens .Black, Xcoord, Ycoord, Diameter,
Public Property Ycoord() As Integer Diameter)
Get End Sub
Return m_ y Sub Move(ByVal distance As Integer)
End Get Xcoord += distance
Set (ByVal value As Integer) Ycoord += distance
m_y = value End Sub
End Set End Class 'Circle
End Property [Run, and click on the Move button ten times.]
Public Property Diameter() As Integer
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 32
3.3. Inheritance and Overloading Implementation
CLASS RELATIONSHIPS
‒ The three relationships between classes are “use,” “containment,” and
“inheritance.”
‒ One class uses another class if it manipulates objects of that class. We say that
class A contains class B when a member variable of class A has class B as its
type.
‒ Inheritance is a process by which one class (the child class), inherits the
properties, methods, and events of another class (the parent class).
‒ Visual Basic does not support the strict academic definition of inheritance. In
this section, we present programs that illustrate “use” (Example 1) and
“containment” (Example 2).In this section we will be setting variables to
existing objects. In that case, the proper statement is
Set objVar = existingObject
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 33
3.3. Inheritance and Overloading Implementation…1
CLASS RELATIONSHIPS
‒ The child has access to all of its parent's properties, methods and events as
well as to all of its own. If the parent is itself a child , then it and its
children have access to all of its parent's properties, methods and events.
‒ Consider the classes shown in Fig. 3.3.1. All three children inherit
Property A and Sub B from their parent. Child2 and Child3 have an
additional event and a property, respectively.
‒ GrandChild! has access to Property A, Sub B, and Event C from its parent
and adds Function E and Sub F. The collection of a parent class along with
its descendants is called a hierarchy.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 34
3.3. Inheritance and Overloading Implementation…2
CLASS RELATIONSHIPS
Figure. 3.3.1. Example of inheritance hierarchy.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 35
3.3. Inheritance and Overloading Implementation…3
CLASS RELATIONSHIPS
There are two main benefits gained by using inheritance: Fir t, it allows two or more classes
to share some common features yet differentiate themselves on others. Second, it support
code reusability by avoiding the extra effort required to maintain duplicate code in multiple
classes.
For these reasons, inheritance is one of the most powerful tools of object-oriented program-
ming. Considerable work goes into planning and defining the member variables and
methods of the parent class. The child classes are beneficiaries of this effort.
Just as structured programming requires the ability to break complex problems into simpler
subproblems, object-oriented programming requires the skill to identify useful hierarchies
of classes and derived classes. Software engineer are till working on the guidelines for when
and how to establish hierarchies. One useful criterion is the ISA test: If one class is a more
specific case of another class, the first class should be derived from the second class. The
Visual Basic keyword Inherits identifies the parent of a class. The code used to define the
class Parent and its child class Child2 as illustrated in Fig. 3..3.1.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 36
3.3. Inheritance and Overloading Implementation…4
CLASS RELATIONSHIPS
Class Parent
Public Property A
'Property Get and Set blocks
End Property
Sub B()
'Code for Sub procedure B
End Sub
End Class
Class Child2
Inherits Parent
Event C()
End Class
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 37
3.3. Inheritance and Overloading Implementation…5
CLASS RELATIONSHIPS
As Child2 is itself a parent, its child GrandChild! can be declared using a similar statement:
Class GrandChildl
Inherits Child2
Function E()
'Code for function E
End Function
Sub F()
'Code for Sub procedure F
End Sub
End Class
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 38
3.3. Inheritance and Overloading Implementation…6
CLASS RELATIONSHIPS
In the following program, the use r is presented with a basic adding machine.
Example 1
The Calculator class implements the Multiply and Divide methods and inherit the
FirstNumber and SecondNumber properties and the Add and Subtract methods from
its AddingMachine parent. When the Adding Machine radio button is selected, the
user may add or subtract two numbers using an AddingMachine object. When the
Calculator radio button is selected, the user may add, subtract, multiply, or divide
two numbers using a Calculator object. Notice that the multiply and divide buttons
are hidden when the Adding Machine is selected, and how the Click event
procedures for the btnAdd and btnSubtract buttons examine the state of the radio
button to determine which machine to use.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 39
3.3. Inheritance and Overloading Implementation…7
CLASS RELATIONSHIPS
Example 1
Figure 3.3.2
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 40
3.3. Inheritance and Overloading Implementation…7
CLASS RELATIONSHIPS
Example 1 …
Public Class frmCalculate
'Create both machines.
Dim adder As New AddingMachine()
Dim calc As New Calculator ()
Private Sub radAddingMachine_ CheckedChanged(... ) Handles
radAddingMachine.CheckedChanged
'Hide the multiply and divide functionality.
btnMultiply.Visible = False
btnDivide.Visible = False
End Sub
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 41
3.3. Inheritance and Overloading Implementation…7
CLASS RELATIONSHIPS
Example 1 …
Private Sub radCalculator_ CheckedChanged(... ) Handles radCalculator.CheckedChanged
'Show the multiply and divide functionality.
btnMultiply . Visible = True
btnDivide.Visible= True
End Sub
Private Sub btnAdd Click( ... ) Handles btnAdd.Click
'Add two numbers.
If radAddingMachine.Checked
Then
'If adding machine selected, use 1t to get the result.
adder.FirstNumber = CDbl (txtNumberl.Text)
adder.SecondNumber = CDbl (txtNumber2.Text)
txtResult.Text = CStr (adder.Add)
Else
'If calculator selected, use it to get the result.
calc.FirstNumber = CDbl (txtNumberl.Text)
calc.SecondNumber = CDbl (txtNumber2 . Text)
txtResult .Text = CStr (calc. Add)
End If
End Sub
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 42
3.3. Inheritance and Overloading Implementation…8
CLASS RELATIONSHIPS
Example 1 …
Private Sub btnSubtract_ Click( ... ) Handles btnSubtract.Click
'Subtract two numbers.
If radAddingMachine.Checked
Then
'If adding machine selected, use it to get the result.
adder . FirstNumber = CDbl (txtNumberl.Text)
adder.SecondNumber = CDbl (txtNumber2.Text)
txtResult.Text = CStr (adder . Subtract)
Else
'If calculator selected, use it to get the result.
calc.FirstNumber = CDbl (txtNumberl.Text) calc.SecondNumber = CDbl (txtNumber2.Text)
txtResult . Text = CStr (calc . Subtract)
End If
End Sub
Private Sub btnMultiply_ Click( ... ) Handles btnMultiply.Click
'Multiply two numbers.
calc.FirstNumber = CDbl (txtNumberl.Text)
calc.SecondNumber = CDbl (txtNumber2.Text)
txtResul t . Text = CStr (calc.Multiply)
End Sub
Private Sub btnDivide_ Click ( ... ) Handles btnDivide.Click
'Divide two numbers.
calc . FirstNumber = CDbl (txtNumberl . Text)
calc.SecondNumber = CDbl (txtNumber2.Text)
txtResult . Text = CStr (calc.Divide)
End Sub
End Class 'frmCalculate
Class AddingMachine
Public Property FirstNumber()
As Double
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 43
3.3. Inheritance and Overloading Implementation…9
CLASS RELATIONSHIPS
Example 1 …
Public Property SecondNurnber () As Double
Function Add() As Double
Return FirstNurnber + SecondNurnber
End Function
Function Subtract() As Double
Return FirstNurnber - SecondNurnber
End Function
End Class
'AddingMachine
Class Calculator
Inherits AddingMachine
'Calculator inherits properties FirstNurnber and SecondNurnber
'and functions Add() and Subtract().
Function Multiply()
As Double
Return FirstNurnber * SecondNurnber
End Function
Function Divide() As Double
Return FirstNurnber / SecondNurnber
End Function
End Class
'Calculator
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 44
3.3. Inheritance and Overloading Implementation…10
CLASS RELATIONSHIPS
Example 1 …
[Run, type in 12 and 3, and click on the + and - buttons. Click on the
Calculator radio button, and click on the +,-, X , and buttons. ]
Figure 3.3.3
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 45
3.3. Inheritance and Overloading Implementation…11
Polymorphism and Overriding
The set of properties, methods, and events for a class is called the class
interface. ln essence, the interface of a class defines how it should
behave. The interfaces of the classes AddingMachine and Calculator
used in Example 1 are shown in Table 11.3.
Consider the classes used in Examples 1 and 2 of Section 11.1. Both
Student and PFStudent have the same interface, even though they carry
out the task of computing a semester grade differently. See Table 11.4.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 46
3.3. Inheritance and Overloading Implementation…12
Polymorphism and Overriding
Table 3.3.1 Interfaces used in Example 1.
Table 3.3.2. Interfaces used in
Examples 1 and 2 in Section
3.3.1.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 47
3.3. Inheritance and Overloading Implementation…13
Polymorphism and Overriding
‒ If a programmer wants to write a program that manipulates objects from these two classes, he or
she need only know how to use the interface. The programmer need not be concerned with what
specific implementation of that interface is being used. The object will then behave according to
its specific implementation.
‒ The programmer need only be aware of the CalcSemGrade method and needn't be concerned
about its implementation. The feature that two classes can have methods that are named the same
and have essentially the same purpose, but different implementations, is called polymorphism.
‒ A programmer may employ polymorphism in three easy steps. First, the properties, methods, and
events that make up an interface are defined. Second, a parent class is created that per forms the
functionality dictated by the interface. Finally, a child class inherits the parent and override the
methods that require different implementation than the parent. The keyword Overridable is used
to designate the parent's methods that can be overridden, and the keyword Overrides is used to
designate the child's methods that are doing the overriding.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 48
3.3. Inheritance and Overloading Implementation…14
Polymorphism and Overriding
‒ There are situation where a child class needs to access the parent class's
implementation of a method that the child is overriding. Visual Basic
provides the keyword MyBase to support this functionality.
‒ Consider the code from Example 1 of Section 3.3.1. To employ
polymorphism, the keyword Overridable is inserted into the header of the
CalcSemGrade method in the Student class:
Overridable Function CalcSemGrade( ) As String
‒ The PFStudent class inherits all of the properties and methods from its
parent, overriding the CalcSemGrade method as follows:
Class PFStudent
Inherits Student
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 49
3.3. Inheritance and Overloading Implementation…15
Polymorphism and Overriding
Overrides Function CalcSemGrade() As String
'The student's grade for the semester
If MyBase .CalcSemGrade = "F" Then
Return "Fail"
Else
Return "Pass"
End If
End Function
'PFStudent
End Class
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 50
3.3. Inheritance and Overloading Implementation…16
Polymorphism and Overriding
Example 2. In the following program, the user can enter student information
and display the semester grades for the class. The PFStudent class inherits all
of the properties from its parent Student, but overrides the CalcSemGrade
method with it own implementation.. The btn.Enter_Click event procedure
stores an element created by either class into the students array. However, the
btnDisplay_Click
event procedure does not need to know which elements are from which class,
thus
demonstrating polymorphism. Note: In. the sixth line of the btn._Enter event
procedure, the statement pupil = New PFStudent () is valid, since, due to
inheritance, every PFStudent is a Student.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 51
3.3. Inheritance and Overloading Implementation…17
Polymorphism and Overriding
Example 2 …1 Figure 3.3.4
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 52
3.3. Inheritance and Overloading Implementation…18
Polymorphism and Overriding CDbl(txtMidterm.Text) 33. dgvGrades.DataSource =
Example 2 …2 query.ToList
17. pupil.Final =
1. Public Class frmGrades CDbl(txtFinal.Text) 34. dgvGrades.CurrentCell = Nothing
2. Dim students(50) As Student 18. 'Add the student to the array. 35.
'Stores the class dgvGrades.Columns("Name").HeaderText =
19. lastStudentAdded += 1
3. Dim lastStudentAdded As Integer = - "Student Name"
1 'Last student added to students( ) 20. students(lastStudentAdded) =
36.
pupil
4. Private Sub btnEnter_Click(sender dgvGrades.Columns("SocSecNum").HeaderTe
As Object, e As EventArgs) Handles 21. 'Clear text boxes and list box. xt = "SSN"
btnEnter.Click 22. txtName.Clear() 37. dgvGrades.Columns("CalcSemGrade").Heade
5. 'Stores a student into the rText = "Grade"
23. mtbSSN.Clear()
array. 38. ReDim Preserve students(50)
24. txtMidterm.Clear()
6. Dim pupil As Student 39. txtName.Focus()
25. txtFinal.Clear()
7. 'Create the appropriate Object 40. End Sub
depending upon the rad1o button. 26. MessageBox.Show("Student #" &
lastStudentAdded + 1 & " recorded. ")
8. If radPassFail.Checked Then
27. txtName.Focus() 41. Private Sub Button3_Click(sender As
9. pupil = New PFStudent() Object, e As EventArgs) Handles
28. End Sub
10. Else Button3.Click
29. Private Sub btnDisplay_Click(sender
11. pupil = New Student() 42. 'Quit the program
As Object, e As EventArgs) Handles
12. End If btnDisplay.Click 43. Me.Close()
13. 'Store the values in the text 30. ReDim Preserve 44. End Sub
boxes into the object . students(lastStudentAdded)
45. End Class
14. pupil.Name = txtName.Text 31. Dim query = From pupil In
students
15. pupil.SocSecNum = mtbSSN.Text
32. Select pupil.Name,
16. pupil.Midterm = pupil.SocSecNum, pupil.CalcSemGrade
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 53
3.3. Inheritance and Overloading Implementation…19
Polymorphism and Overriding Final() As Double 27. Return "A"
14. 'The student's score 28. Case Is >= 80
Example 2 …3 on the final exam 29. Return "B"
1. Public Class Student 15. Set(ByVal value As 30. Case Is >= 70
2. 'Member variables to hold the Double) 31. Return "C"
property values 16. m_final = value 32. Case Is >= 60
3. Private m_midterm As 17. End Set 33. Return "D"
Double 18. End Property 34. Case Else
4. Private m_final As Double 19. Overridable Function 35. Return "F"
5. Public Property Name() As CalcSemGrade() As String 36. End Select
String 20. 'the Student's grade 37. End Function
6. Public Property for the semester 38. End Class 'Student
SocSecNum() As String 21. Dim grade As Double
7. Public WriteOnly Property 22. 'the grade is based
Midterm() As Double upon average of the midterm
8. 'The student's score and final
on the midterm exam 23. grade = (m_midterm +
9. Set(ByVal value As m_final) / 2
Double) 24. grade =
10. m_midterm = value Math.Round(grade) 'Round the
11. End Set grade.
12. End Property 25. Select Case grade
13. Public WriteOnly Property 26. Case Is >= 90
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 54
3.3. Inheritance and Overloading Implementation…20
Polymorphism and Overriding
Example 2 …4
1. Public Class PFStudent
2. Inherits Student
3. Overrides Function CalcSemGrade() As String
4. 'the students Grade for the semester
5. If MyBase.CalcSemGrade = "F" Then
6. Return "Fail"
7. Else
8. Return "Pass"
9. End If
10. End Function
11. End Class 'PFStudent Figure 3.3.5
[Enter the data and click on the Enter Information button for three students. Then click on the Display Grades
button, and finally enter the data for another student.]
Example 2 employ inheritance and overriding to provide functionality to one child class. lf a program
contains two or more children of a class, however, the technique of overriding can lead to confusing programs.
Visual Basic provides a cleaner design through the use of abstract classes .
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 55
3.3. Inheritance and Overloading Implementation…21
Abstract Properties, Methods, and Classes
‒ Sometimes you want to insist that each child of a class have a certain
property or method that it must implement for its own use. Such a
property or meth od is said to be abstract and is declared with the keyword
MustOverride. An abstract property or method consists of just a header
with no code following it.
‒ It has no corresponding End Property, End sub, or End Function
statement.
‒ Its class is called an abstract base class and must be declared with the
keyword Mustlnherit.
‒ classes cannot be instantiated; only their children can be instantiated.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 56
3.3. Inheritance and Overloading Implementation…22
Abstract Properties, Methods, and Classes
Example 3 The following program calculates the area of several regular two-
dimensional shapes, given the length of one side. (A regular shape is a
shape whose sides have identical length and whose interior angles are
identical.) The abstract parent class shape implements the Length
property and declares the Name and Area functions a MustOverride.
Notice that method declared with MustOverride do not have any
implementation code. Each child class inherits the property from the
parent and implements the two functions. The btnDisplay_Click event
procedure uses polymorphism to set the shapes' length and display the
shapes' names and areas.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 57
3.3. Inheritance and Overloading Implementation…23
Abstract Properties, Methods, and Classes
Example 3 …1
Public Class frmShapes
'Declare shape array.
Dim shape(3) As Shape Figure 3.3.6
Private Sub frmShapes_ Load( ... ) Handles MyBase .Load
'Populate the array with shapes.
shape(O) New EquilateralTriangle ()
shape(l) = New Square ()
shape(2) = New Pentagon ()
shape(3) = New Hexagon ()
End Sub
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 58
3.3. Inheritance and Overloading Implementation…24
Abstract Properties, Methods, and Classes
Example 3 …1
Private Sub btnDisplay_ Click( . .. ) Handles btnDisplay.Click
Dim length As Double
'Set lengths of all shapes.
length= CDbl (txtLength.Text)
For i As Integer = 0 To 3
shape(i) .Length= length
Next
'Display results.
lstOutput.Items.Clear()
For i As Integer = 0 To 3
lstOutput.Items.Add( "The " & shape( i ) . Name & " has area " &
FormatNumber(shape(i) .Area)) & " "
Next
End Sub
End Class 'frmShapes
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 59
3.3. Inheritance and Overloading Implementation…25
Abstract Properties, Methods, and Classes
Example 3 …1
Mustinherit Class Shape
Public Property Length() As Double
MustOverride Function Name() As String
'Returns the name of the shape.
MustOverride Function Area() As Double
'Retu ns the area of the shape.
End Class
'Shape
Class EquilateralTriangle
Inherits Shape
Overrides Function Name() As String
'The name of this shape
Return "Equilateral Triangle"
End Function
Overrides Function Area() As Double
'Formula for the area o an equilateral tr1angle
Return Length* Length* Ma th.Sqrt(3) I 4
End Function
End Class
'EquilateralTriangle
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 60
3.3. Inheritance and Overloading Implementation…25
Abstract Properties, Methods, and Classes
Example 3 …1
Mustinherit Class Shape
Public Property Length() As Double
MustOverride Function Name() As String
'Returns the name of the shape.
MustOverride Function Area() As Double
'Retu ns the area of the shape.
End Class
'Shape
Class EquilateralTriangle
Inherits Shape
Overrides Function Name() As String
'The name of this shape
Return "Equilateral Triangle"
End Function
Overrides Function Area() As Double
'Formula for the area o an equilateral tr1angle
Return Length* Length* Ma th.Sqrt(3) I 4
End Function
End Class
'EquilateralTriangle
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 61
3.3. Inheritance and Overloading Implementation…26
Abstract Properties, Methods, and Classes
Example 3 …1
Class Square
Inherits Shape
Overrides Function Name() As String
'The name of this shape
Return "Square"
End Function
Overrides Function Area() As Double
'Formula for the area of square
Return Length * Length
End Function
End Class 'Square
Class Pentagon
Inherits Shape
Overrides Function Name() As String
'The name of th1s o ap
Return "Pentagon"
End Function
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 62
3.3. Inheritance and Overloading Implementation…27
Abstract Properties, Methods, and Classes
Example 3 …1
overrides Function Area() As Double
'Formula for the area of a pentagon
Return Length* Length* Math . Sqrt(25 + (10 * Math . Sqrt(5)) ) I 4
End Function
End Class ‘Pentagon
Class Hexagon
Inherits Shape
Overrides Function Name() As String
'The name of this shape
Return "Hexagon"
End Function
Overrides Function Area () As Double
• Formula for the area of hexagon
Return Length * Length* 3 * Math .Sqrt(3) / 2
End Function
End Class ‘Hexagon Figure 3.3.7
[Run the program, enter 5, and click on the Display button.]
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 63
3.3. Inheritance and Overloading Implementation…40
SUMMARY
1. An object is an entity that stores data, has methods that manipulate the data, and can raise events. A
class is a template from which objects are created. A method specifies the way in which an object'
data are manipulated. An event is a message sent by an object to signal the occurrence of a
condition.
2. Each class is defined in a separate block of code starting with Class ClassName and ending with
End Class. Data are stored in member variable and accessed by procedures called properties.
3. A property routine contains a Get block to retrieve the value of a member variable or a Set block to
assign a value to a member variable. These procedures can also be used to enforce constraints and
carry out validation.
4. Visual Basic automatically invokes a New procedure when an object is created.
5. A n object variable is declared with a statement of the form Dim objectName As ClassName, and
the object is created with a statement of the form objectName = New ClassName ( argl, arg2, ••• ) .
These two statements are often combined into the single statement Dim
objectName As New ClassName(argl, arg2, ... ).
6. Auto-implemented properties enable you to quickly specify a property of a class without having to
write code to Get and Set the property.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 64
3.4. Classes Versus Components
Creating and Using Components in Visual Basic
‒ A component is a class that implements the System.ComponentModel.IComponent interface or
that derives directly or indirectly from a class that implements IComponent. A .NET component
is an object that is reusable, can interact with other objects, and provides control over external
resources and design-time support.
‒ An important feature of components is that they are designable, which means that a class that is a
component can be used in the Visual Studio Integrated Development Environment. A component
can be added to the Toolbox, dragged and dropped onto a form, and manipulated on a design
surface. Base design-time support for components is built into .NET. A component developer
does not have to do any additional work to take advantage of the base design-time functionality.
‒ A control is similar to a component, as both are designable. However, a control provides a user
interface, while a component does not. A control must derive from one of the base control
classes: Control or Control.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 65
3.4. Classes Versus Components…1
Creating and Using Components in Visual Basic
When to Create a Component
‒ If your class will be used on a design surface (such as the Windows Forms or Web
Forms Designer) but has no user interface, it should be a component and
implement IComponent, or derive from a class that directly or indirectly
implements IComponent.
‒ The Component and MarshalByValueComponent classes are base implementations of
the IComponent interface. The main difference between these classes is that
the Component class is marshalled by reference, while IComponent is marshalled by
value. The following list provides broad guidelines for implementers.
• If your component needs to be marshalled by reference, derive from Component.
• If your component needs to be marshalled by value, derive
from MarshalByValueComponent.
• If your component cannot derive from one of the base implementations due to single
inheritance, implement IComponent.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 66
3.4. Classes Versus Components…2
Creating and Using Components in Visual Basic
Component Classes
‒ The System.ComponentModel namespace provides classes that are used to
implement the run-time and design-time behavior of components and controls.
This namespace includes the base classes and interfaces for implementing
attributes and type converters, binding to data sources, and licensing
components.
‒ The core component classes are:
• Component. A base implementation for the IComponent interface. This class
enables object sharing between applications.
• MarshalByValueComponent. A base implementation for
the IComponent interface.
• Container. The base implementation for the IContainer interface. This class
encapsulates zero or more components.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 67
3.4. Classes Versus Components…3
Creating and Using Components in Visual Basic
Some of the classes used for component licensing are:
• License. The abstract base class for all licenses. A license is granted to a specific instance of a
component.
• LicenseManager. Provides properties and methods to add a license to a component and to
manage a LicenseProvider.
• LicenseProvider. The abstract base class for implementing a license provider.
• LicenseProviderAttribute. Specifies the LicenseProvider class to use with a class.
Classes commonly used for describing and persisting components.
• TypeDescriptor. Provides information about the characteristics for a component, such as its
attributes, properties, and events.
• EventDescriptor. Provides information about an event.
• PropertyDescriptor. Provides information about a property.
6/5/2023 EDP CH3 compiled by ydereje2020@gmail.com 68