Re: class module?
- From: BAC <BAC@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 16 Jun 2005 11:49:10 -0700
Think of a "Class" as a series of subroutines and functions that build a car
(kinda like a dll). The Functions return values for the characteristics (or
"adjectives") that describe the car (e.g. color, trim, interior). These are
called properties.
The subroutines cause the car to do certain things (Speed up, slow down,
stop). These are called methods.
Once you write the code, to slow down, for example:
Sub Slow_down(mph)
do until car.speed = mph
apply brakes 'Which may be another "method"
loop
end sub
You never have to write this code again. Instead, you can simply invoke the
"Slow_down" method of the car class and pass it the desired speed.
Had I created a "Property" named "Speed" for the car, I could have set the
"property" with setProperty to the lower speed:
Function speed(mph)
set property car.speed = mph
end function
Now I can create any number of cars (objects) with any number of
characteristics, and have them do any number of things, just by calling the
Dll (called "instantiating" or "creating an instance of") and passing in the
specific Function (setting the properties) or Subroutine (invoking the
methods) parameters rather than writing the code whatever number of times.
Clearly an "oversimplification" but, pretty much the basics of OOP. Program
the "object" car by setting its properties and invoking its methods, rather
than programming the computer to do these things
As one of us "old timers" surely you remember writing the BASIC code to
create a string of "-"s to form a line across the screen to create a display
box. Then counting pixels and spaces to fill the box with text. Well, now, we
only need to set the properties of the TextBox object and all that code
"happens" because somebody created a TextBox class of object..
Clearer?
BAC
"Henry" wrote:
> Jim and others,
>
> I consider myself a fairly competent amateur programmer.
> I have an above average IQ. (not quite Mensa standard).
> I understand most, if not all, the principles of programming.
> I've written several programs in Excel (and some Word) VBA and even written
> an assembly language program which I was selling.
> (Ancient history. It was in Z80 code for the Spectrum. About 5K lines of
> code.)
> I've mainly taught myself to do most of this, with some help from books,
> this group and others.
> I attended a programming course at the local college, which I failed,
> because nobody could explain to ME how OOP worked.
> Others in the class seemed to get it. Maybe I'm too entrenched in *normal*
> coding to take it on board?
> I can break a problem down into the small steps necessary to program, but I
> just can't seem to make the"leap of faith" into OOP.
> Now, if someone out there could explain it to me, in words of one syllable,
> preferably with simple examples, I might get it.
>
> So, come on people, try explaining it to me in a way that doesn't go 6
> inches above my head.
> Or at least point me to somewhere where I can try to get to grips with it.
>
> Henry
>
> "Jim Thomlinson" <jamest@xxxxxxxxxxxxxxxxxxxx> wrote in message
> news:4AD8F108-8799-47AC-A3DF-5B08CAAE2642@xxxxxxxxxxxxxxxx
> >I think we have been here once before... An explanation of classes is a
> > little beyond the scope of this forum. Classes are more the kind of thing
> > you
> > need to take a programming course in Object Oriented Programming to get.
> > In a
> > nut shell however... Classes are blueprints to create objects. Objects are
> > things (almost tangible) which use as a programmer can interact with.
> > Objects
> > have properties and methods. Properties describe the object. Methods are
> > things an object can do.
> >
> > Classes are not terribly applicable to Excel programming. They are used
> > very
> > rarely (I only use them to handle events). It is great to understand
> > objects
> > and classes and they will make a lot of things in the world of the Excel
> > object model more understandable but they are not for the beginner or the
> > faint of heart.
> > --
> > HTH...
> >
> > Jim Thomlinson
> >
> >
> > "sybmathics" wrote:
> >
> >> Hi,
> >>
> >> At what occasion do you create a class module?
> >> What can class modules do?
> >>
> >> How do you fill a class module?
> >>
> >> I know about modules and user-functions as addinn, how to create a
> >> user-form.
> >>
> >> I don't know anything about class-modules.
> >>
> >> Can anyone explain?
> >>
> >> greets,
> >>
> >> Sybolt
> >>
> >>
> >>
>
>
>
.
- Follow-Ups:
- Re: class module?
- From: Henry
- Re: class module?
- From: Henry
- Re: class module?
- References:
- class module?
- From: sybmathics
- RE: class module?
- From: Jim Thomlinson
- Re: class module?
- From: Henry
- class module?
- Prev by Date: Re: Get the Excel Filename after a save
- Next by Date: Re: Batching files through a macro
- Previous by thread: Re: class module?
- Next by thread: Re: class module?
- Index(es):
Relevant Pages
|
Loading