The first thing to remember is not to get all caught up in the jargon.
A class is usually a file, much like a text file that holds some code. For organizational purposes, think of a class as a component of some larger system.
If a peanut butter and jelly sandwich program were to be decompiled, there would be several classes involved, one for each of the ingredients in the sandwich.
The Classes would contain code that define the item and give it functional parameters. In addition, the code could contain additional routines to assist the class object perform its objective, such as converting data to a proper format
(eg; changing a integer to a string or getting some data from a database)
The routines or members of a class are restricted to subs or functions.
A sub is a piece of code that performs some action, but does not return any information to the member that calls it.
Ex.
An error occurs within some code and it jumps to the error catch segment to alert the programmer. Within the error catch, you could call a sub to send a notification email to the admin. After the email sub finishes, the code path would return to the error secti0n of the member and continue its course.
A Function is a piece of code that returns some type of information to the member that calls it.
ex.
A program for retrieving data from a database and appending it to a text file has retrieved the majority of the data it needs from database A. However, it needs a few phonenumbers from database B.
Simple. Just create a new function called DatabaseBDataGrab with a database query that returns the value needed.
here is sample code, simplified:
Explanations are after the asterisk to the right of the code
Function DatabaseBDataGrab(byval accountnum as integer) as integer
* this is the signature. it goes in the following order: Type of Member, Name of member, (name and type of variable being passed into the member),type of data return.
dim datbaseconnection as new DatabaseConnectionClass
* we summon an instance of the class that performs all the database functions
dim result as integer=0
*create a variable to act as your result
dim sql as string=”Select phonenumber from db.PhonenumberTable where Phone_Table_Accountnum=’” & accountnum & “‘ ”
*create a variable string that holds the text for the db query
result=databaseconnection.Performquery(sql)
* call the databaseconnection function that runs the query and assign the result to its namesake
return result
*return the value from the query to the member that called it.
end function
Thats all for now.