visual basic + classes

Posted on 2003-03-03
Medium Priority
Last Modified: 2013-11-25

I am very new to visual basic I have only been working with it the last 2 months.  Also I have never had the opportunity to learn much about classes. I was wondering if someone out there could help me with this. I need a good example of a class and how to use it in visual basic.  any information links to websites with tutorials is much welcome even a chunk of code as an example would be wonderful.

thanks very much in advance. points will go to who ever gives me the code that helps me the most :)


Question by:laurly
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

marconovaro earned 150 total points
ID: 8055838

Your question is somehow generic. But I'll try to explain.
Classes in VB (as in other programming languages) are a way to describe "objects" in the code. This makes an Object Oriented programming language (even if you can discuss if VB is really a OO language! ).

A class describes the properties and the methods of the object that it describes.
Maybe an example is better: we have to use an animal in the code. The animal has some properties (weigth, type, etc.), and some methods (e.g. bites, barks, etc.). You can describe it in a class where:

Private m_AnimalType as integer

Property Get Type() as integer
    Type = m_AnimalType
End Property

Property Get Type(value as integer)
    m_AnimalType = value
End Property

Pubilc Sub Bite()
    ' Do something  
End Sub

And you can use it like this:

dim myAn as cAnimal

' Create a new animal:
set myAn = new cAnimal

myAn.Type = 10

Hope this helps,


Expert Comment

ID: 8056118
look for it in MSDN Library : http://msdn.microsoft.com/

Expert Comment

ID: 8940402
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
LVL 49

Expert Comment

ID: 9012117
Moderator, my recommended disposition is:

    Accept marconovaro's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer

Author Comment

ID: 9017531
marconovaro anwser was not detailed enough to actualy work. I tryed it sevral times and never figured out how to get it to work. there is no infomration on how to create the class and where to put what code.

fluglash bugs comment was also not detailed enough.  I knew this sight already and it is not helpful.

What i was looking for was a very detailed beginner example of how and why to use classes in visualbasic.  None of these anwsers fit what i needed.  I have been working on my own with this since i asked this question  But still do not feel i have enough information on the subject.

I would rather not delete the queiston becouse i am still hoping that someone will post the help i am looking for.  But as none of these anwsers fit what i need and you want it finalized you may delete it if necessary.


Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question