An Introduction to Object Oriented Database Development with VB.NET 2005 - Explaining the class
(Page 2 of 5 )
From the above code, you must be able to understand that I added a class to my solution named “Emp.” When we speak about a class, we need to know its “members” as well. Within the above class, we have the following “class members:”
- m_empno
- m_ename
- m_sal
- m_deptno
- load
Of all of the above, the first four members (m_empno, m_ename, m_sal and m_deptno) are generally termed fields/attributes/member variables/class level variables. Since we defined all members as “public,” all of them are accessible everywhere (including within the class). I shall explain accessibility options later in my upcoming articles.
There exists one more member, called “load.” It is not a variable. It is a sub-routine containing some logic. Any sub-routine/function available in class is generally termed a “method.” To put it simply, the class “emp” contains five “members,” where four are the “fields” and one is the “method.”
There can be several types of “methods” in a class. Some methods may be defined as sub-routines and others as functions. A sub-routine doesn’t return a value, whereas a function would return something. They are also described as “methods not returning values” (sub-routines) and “methods returning values” (functions). Some methods may also be defined with some “parameters,” to pass some values to them. They are generally termed “methods with parameters.”
In our case “load” is a “method not returning a value” and also a “method accepting a parameter.” It is mainly used to encapsulate the logic of retrieving the employee information from the database.
Next: Explanation continued >>
More Visual Basic.NET Articles
More By Jagadish Chaterjee