Results 1 to 4 of 4

Thread: Any decent e-books for learning classes?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    83

    Any decent e-books for learning classes?

    Looking for some tuts / books for learning classes, I've read quite a few e-books but they don't focus primarily on them, any decent ones people have read and they recommend?

    Cheers.

  2. #2

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2009
    Posts
    83

    Re: Any decent e-books for learning classes?

    Quote Originally Posted by jmcilhinney View Post
    I've read that one before, only problem is that it doesn't go into great detail and everything you can do in those tutorials with the class you can just do in a module, doesn't really tell you the differences.

    Thanks tho.

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,158

    Re: Any decent e-books for learning classes?

    The difference is simple: a module cannot be instantiated and a class can. A module is like a class with all Shared members.

    Take a simple example. Consider an application that displays information to the user about people, e.g. given name, family name, date of birth, etc. Now, you could use a module to describe a person but that module can only store one set of data, so you can only store data about one person at a time. What if you want to display a list of people? With a module, you couldn't. You need a class that has the appropriate properties to describe a person, then you need to create multiple instances of that class to store information about multiple people.

    As another example, consider the controls you place on a form. They are all classes. Again, if they were modules then you could only ever display one of each type of control at a time. In order to display two TextBoxes you must created two instances of the TextBox class.

    Particularly for simple applications, you could do most of what you need to do using modules, or even one module, but that's not the way to do things in VB.NET. VB.NET is an object oriented langauge so you should use it as such, which means using classes. Using classes instead of modules simply means creating an instance of the appropriate class before accessing the data it contains, while with a module you simply go ahead and access the data. That is the one and only fundamental difference.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width