-
Questions about Classes
Howdy all,
I have a question about classes. I have a vague understanding as to how a class works and what it's purpose is. I am currently reading a chapter in a book on the subject. I have a question to you all:
What makes a class better than a well structured module?
From many of the downloaded source code files for VB programs, I see that classes are used quite extensively. Why? Again, I vaguely understand how classes work. That is you can have a class that describes a car, and all of the attributes of that car. What I do not understand is how.
Do you know of any great tutorials that help make learning this topic any easier? The book is ok, but I am getting a bit lossed. Any additional info on the subject would be helpful in my understanding of it. I consider myself an intermediate VB programmer, and I have made a number of cool programs for past and present jobs, but I feel I need to expand into these more advanced topics (such as object oriented programming) so I can 'run with the big dogs'.
What are your opinions? I really appreciate your time...
-
Are you reading beginning visual basic .net with wrox? They have that same car example!!
Ok... a class and a very well organized module can do the same thing in the end. Just a class can be reused. Say you have form1 and form2, you would have to put the same exact code into both forms for what you're talking about a well coded module. But a class can be reused over and over again making it much more efficient in the end.
Also... if you don't understand what a class is, you know how you have ... hmm... lemme look into my book. In chapter 3 of the book i mentioned above, it has this: subfolder.fullname
The 'subfolder' part is like the class name and the 'fullname' part is like a property that you program into a class. Everything you do in visual basics is pretty much a class. The whole .net framework is just thousands of thousands of classes!!!
-
Here is a tutorial from VBWorld, its actually a 3 part series:
http://216.26.168.92/activex/comcourse/
Classes are objects without a visual interface, somewhat like a control. If you put your code in a module you can't have multiple instances of it running at once. That is one difference. I think once you learn about classes and start to use them you will realize their usefullness.