DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Visual Basic 4 / 5 / 6 (http://www.daniweb.com/forums/forum4.html)
-   -   USING CLASSES in VB6 (http://www.daniweb.com/forums/thread24074.html)

vhinehds May 23rd, 2005 2:53 am
USING CLASSES in VB6
 
hi its me again...

can someone please explain what a class can do? how to call a class?
or if just give me a good link where i can refer to it.

thanks a lot.

Comatose May 23rd, 2005 12:06 pm
Re: USING CLASSES in VB6
 
I'll do both. Without going into crazy whacky details, a class is basically the base for creating your own objects. In order to do this, you add a "Class Module" to Your VB6 project, and you can build your own object. This object can be anything and do anything... it can have it's own properties, it's own methods, a constructor, and a destructor. In VB you can then instantiate an instance of this class as an object, and use it just like any other object.

and a link:
http://64.233.167.104/search?q=cache...hl=en&start=19

bouzahme Jun 9th, 2005 3:31 pm
Re: USING CLASSES in VB6
 
Hi,
What is a class?
A class can be defined a structure that is composed of two things:
- Data Members.
- Methods.
A class is designed to be reused, when using a class we dont have to know, how it is designed, we just need to know the interface and methods signatures.

Why using a class in vb?
We use class to create composant that can be reused in other application.
Such example, creating a class that do the following:
- Create an ODBC connection to a Database,
- Create an OLEDB connection,
- Get a recordset from the DB,
- Execute Function (Insert, Update, ...statements)
- Check if a connection status to a DB,...
As you can se this functions are already used to deal with a DB.

How to use a class?
You have to create an instance of that class (called object)
We have a compoent called dataLayer in which there is a class called clsDataLayer, some of it's methods are ODBCConnect,GetDisRecordsetPage...

Dim oData as new datalayer.clsdtalayer
Dim MyCnn as new adodb.Connection

set MyCnn =oData.ODBCConnect("DsnEssai")

Regards

Comatose Jun 9th, 2005 4:16 pm
Re: USING CLASSES in VB6
 
Do me a big favor... when you post, use code tags. You can do that like this
[ CODE]
dim ADO as object
[ /CODE]

with no spaces between the [ and the word or /. Anyway, it helps to make the posts a little bit more readable, and helps make the post more organized. Thanks.

EricaJanine Jun 9th, 2005 9:41 pm
Re: USING CLASSES in VB6
 
Also, the main thing about a class is that it is not a module (.bas) file. Like it was already stated, you can create an instance of a class and access all of its public methods and members.

Did that clear everything up, or do you still have questions?

:cool:

 
if (codeWritten = true) and (codePosted = true) then
  objComatose.happy = true
else
  objComatose.rant = true
end if

Comatose Jun 9th, 2005 9:44 pm
Re: USING CLASSES in VB6
 
Are You Saying I Rant? ;)

EricaJanine Jun 9th, 2005 9:45 pm
Re: USING CLASSES in VB6
 
Maybe the Shaolin of Rant. :cheesy:

Comatose Jun 9th, 2005 9:47 pm
Re: USING CLASSES in VB6
 
Is That A Good Thing, or a bad one?
Uh Oh, I'm being Monitored.... Quick, put away the big black VB book...

EricaJanine Jun 9th, 2005 9:48 pm
Re: USING CLASSES in VB6
 
Nah, just ran across another thread on here...thought it was pretty funny, actually.

Comatose Jun 9th, 2005 9:49 pm
Re: USING CLASSES in VB6
 
:) Thanx, I have my moments...

vhinehds Jun 12th, 2005 3:07 am
Re: USING CLASSES in VB6
 
Quote:

Originally Posted by Comatose
:) Thanx, I have my moments...


hi guys!

well until now i cant still figure out how to make classes...
can you give me a basic example of creating a class and how can i use it in my coding? thanks a lot.

jwshepherd Jun 16th, 2005 1:00 am
Re: USING CLASSES in VB6
 
check the code snippets to the left there isone in there

Bharati Krishna Jun 16th, 2005 3:45 am
Re: USING CLASSES in VB6
 
Hi,

If you want to develop a complete Database Application using classes, I would advise you to refer this book Titled:" Develop an Accounting package using vb and SQL server 2000".

You can build a class to access data (through methods) from SQL server, update data, Managing Connection and any business logic you want build in client side.....

I read this book and developed full accounting Client/server package.

Regards
bhar

Comatose Jun 16th, 2005 7:31 pm
Re: USING CLASSES in VB6
 
Or, Just a simple google search on vb6 class module example turns up quite a bit of good stuff. If you need, I can build one as an example, but there are tons of them out there with a google search.

vhinehds Jun 21st, 2005 7:14 am
Re: USING CLASSES in VB6
 
hi comatose sorry its only now i checked my port here...anyway, i would love you'll give me a simple example together with an explanations. because i just find it hard to build my own class, i have difficulty in understanding the procedure of making it.

thanks a lot.

detnikolaids Jul 8th, 2005 3:52 am
Re: USING CLASSES in VB6
 
Hi guys! I'm a newbie here =)
question related to this thread. a module can also be created and re-used across different VB projects. So when is it appropriate to use a class rather than a module?

Bharati Krishna Jul 30th, 2006 6:33 am
Re: USING CLASSES in VB6
 
Hi,

When we want to reuse a functionality, Classes can be used. A module for instance, could be used for a particular form only.

In an accounting application a Class can be used in the following instances:

a.When we want to access data from a database
b.Log in feature in the application
c.Adding data

In the title "Develop an Accounting Package using VB", i have dealt with this topic in detail....A class has been developed and when we save data into the database, retreive, edit, adding and displaying data. All the financial transactions use the Class - Tran Class.

If you notice, suppose we have a Cash Payment transaction, this transction uses the same class as the Cash Voucher transaction uses. I have dealt with how to design single form, and use the same form for different transactions like CV, CP etc, which is OOPs.

If we use a module, we will need to create separate modules .....

Each entity also can be created as a class.

Class based design forces us to think ahead in terms system design and implenting the requirements in a project and thus save on all resources like time, money etc.

Regards
Bhar


All times are GMT -4. The time now is 11:30 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC