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

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


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…

616 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