Hi there,
class modules and standard modules are way apart. I will make the assumtion that you already know what the standard module comprises of, i.e. Functions and subroutines.
1st an explanation then a demo at the bottom
OBJECTS:
Classes define objects, so looking at yourself as an object you have properties, like air colour, height, weight etc. You also have methods, walking, talking, eating etc. Therefore you are an object; where the class comes in is that it defines what an object is.
CLASS:
Working on the latter section we take yourself as an object and strip away the values stored in your properties and methods. The class doesnt say what colour your hair is, it just says that you have hair. The class dosnt say how fast you are walking, it just says there is a method that you can accomplish called walking. The age old analogy that is used is a class is a cookie cutter for an object. It tells it what shape it is but not what it is made of or looks like.
CREATION:
In VB you can create a class in the IDE by adding a class module to your project, or by using the class builder, however thats another story! But one which is a great help! Anyhow, you add a class module. and there you have it, an empty class module.
PROPERTIES:
Now to give it some properties these are simply declarations i.e.
Public strMessage as string
METHODS:
And finally the method! in this case a simple subroutine.
private sub subDisplay()
msgbox strMessage
end sub
and there you have it a class created! So far you have a class which we will name clsMessage which has a property of strMessage and a method of subDisplay. Now to call the class and see it working:
open vb and start a standard exe, now you have a form, now add in a class module. In the class module insert the following code
Public strMessage as string
private sub subDisplay()
msgbox strMessage
end sub
Now go back to the form and double click it, the code needs to look like below:
Private objNewMessage As clsMessage
Private Sub Form_Load()
Set objNewMessage = New clsMessage
End Sub
Finally select the class module and in he properties window call it clsMessage. Now run the program; pause it and open the immediate window.
type in the immediate window
objNewMessage.
and when you should get the tag suggestor suggesting a method of subDisplay and a property of strMessage, so set the property to something.
objNewMessage.strMessage = "Hello World"
then again back to the object and call its method
objNewMessage.subDisplay
voila!!! you should have a messagebox.
What has happened is that the form has created an instance of the class, you have then gone on to creat the object as a whole by assigning it a property and executing a method. You can have more than one instance of these running so lets say you wanted three text boxes you simply do the declarations in the form code however many times you like so you could have
Private objPreviousMessage As clsMessage
Private objThisMessage As clsMessage
Private objNextMessage As clsMessage
Private Sub Form_Load()
Set objPreviousMessage = New clsMessage
Set objThisMessage = New clsMessage
Set objNextMessage = New clsMessage
End Sub
Here endeth the story of the class and the module

) Only for one simple reason, its midnight. Theres loads more and i could go on for days on end becuse OO rocks, even though VB isnt really OO the classes and collections certainly make it worth doing.
I shall let you ponder over that and get your creative juices going and leave you with some other words to have a shiftie at to do with classes
collections (collections for classes)
inheritance (of classes)
terminate (event that all classes have)
initialize ( ditto )
like i say, theres loads more but you get the idea. Owt else then drop me a line.
cheers
'mi casa es su casa'
]-=tty0=-[
ICQ:82621399