• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 153
  • Last Modified:

the differences between Classmodule & Module

iwant to know more informations about Classmodule & Module ihope that the answers with examples ,so as to help me to understand.

thanks for everybody.
  • 2
1 Solution
A bit much to ask... this is one of the major aspects of later versions of VB and it takes a manual to explain it properly. Not something that can be done easily in an EE thread.

Check out the VB help for starters, and if you're really serious about learning, go to your local book shop and check out the computers section. There are some good VB books about.
I think the major difference between CalssModule and Module is that with CalssModule you can use the procedurs with other programs for example :
With VB you can use som Microsoft Word's fonctions that because the function has writen in CalssModule if they where in Module you couldn't use them .

Of corse there are many more thinks you should know about CalssModule but as Caraf_q said it's too large thing to here .

                        Yuval Amir
Thanks vbyuval,

Oh, yes, my profile is caraf_g. It's the EE font that makes it look like caraf q.
A module is like a toolbox : you put in variables and functions that will be available to any code to which the module is visible.

A class module is a blueprint for an object : usually, some user-defined data type and all the functions needed to access and work on that data. Only the functions and variables that are Public can be seen from outside the object.

For instance, if you have a class named clsPerson that defines a person, you might have something like:

private intAge as integer
private strName as string
private strAddress as string

Public Property Get Age() as integer
    Age = intAge
end Property

Public Property Let Age(intNewAge as integer)
    if intNewAge < 125 then
        intAge = intNewAge
    end if
End Property

Public Function Talk() as string
    Talk = "Hello there."
End Sub

.... ans so on.

The idea here is that you can have several persons with different information, but they have the same type of information, and the validation is directly tied to the data.

So you can do something like :

Dim Bob as New clsPerson
Dim Bill as New clsPerson

Bob.Age = 33

Bill.Age = 21

Debug.Print Bill.Talk

but you can't do this :

Bill.intAge = 33

because intAge is private.

So each Instance (or distinct object) corresponds to the definition (Class).

And you can protect the variables from irrelevant value by validating the input.

As was mentioned in previous answers, object-oriented programming is quite an elaborate subject. This is barely scratching the surface.

I hope it helps.

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now