BAC,
Thanks for that.
It hasn't parsed yet, but looks like it will after a few read throughs.
I'm very tired at the moment, maybe at the weekend when I'm more relaxed
it'll sink in.
Henry
> Think of a "Class" as a series of subroutines and functions that build a
> car
[quoted text clipped - 125 lines]
>> >>
>> >> Sybolt
> Think of a "Class" as a series of subroutines and functions that build a
> car
[quoted text clipped - 14 lines]
> loop
> end sub
Re-usable code!
I understand that and have done it many times.
Especially when programming for the Spectrum, where you've only got 48K of
memory to play with.
Put the code in a sub and call it from wherever it's needed, passing any
desired data to it.
> You never have to write this code again. Instead, you can simply invoke
> the
[quoted text clipped - 6 lines]
> set property car.speed = mph
> end function
Got that.
> 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
[quoted text clipped - 3 lines]
> specific Function (setting the properties) or Subroutine (invoking the
> methods) parameters rather than writing the code whatever number of times.
Sort of got that. Still not quite sunk in. I'll ponder a little longer on
that.
> 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
Now that's the bit that I never got before.
Mainly because it goes against all my programming experience.
It's a little clearer now, but not fully there yet.
> 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
[quoted text clipped - 3 lines]
> only need to set the properties of the TextBox object and all that code
> "happens" because somebody created a TextBox class of object..
I've done that in Assembly Language.
Write a sub that accepts all the required parameters to display a textbox or
whatever.
Call it from elsewhere in the code, passing the parameters to the sub, and
the textbox or whatever appears on screen.
I never thought of it as OOP before.
Come to think of it, I've done it in Excel VBA.
I wrote a sub to show my own MsgBox so that I could have different colours,
font sizes, etc.
Call MyMsgSub ("Message","Title", Integer Variable)
The Integer Variable defines the appearance of the MsgBox.
If that's OOP, its easy.
I still don't fully understand the concept, though.
I'm probably more practical than theoretical in this sort of thing.
Quite often I find that I know *how* to make it work, but not *why* it
works.
> Clearer?
A little clearer, thanks.
Still not fully confident that I understand.
> BAC
Thanks for your time.
Henry
<SNIP>
keepITcool - 22 Jun 2005 08:12 GMT
Henry wrote :
> Call MyMsgSub ("Message","Title", Integer Variable)
> The Integer Variable defines the appearance of the MsgBox.
> If that's OOP, its easy.
that is NOT oop.
oop would be more like:
dim myBox as CBox
set myBox = new Cbox
mybox.setsize(10,20,30)
mybox.type = btPizza
mybox.material = bmPlyWood
msgbox mybox.Volume, myBox.Weight
--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam
Fran D - 19 Feb 2006 18:30 GMT
Dear All
I am trying to develop a big class module that will include few other
smaller class modules for easy data transfer. The main module would
allow to manipulate properties easily, something like
.HR.Secretary.name
.HR.Secretary.address1
.HR.Secretary.SalaryBand.GrossAnualIncome
.HR.Secretary.SalaryBand.YearsEmployment
the model to be used is someting like
".Department.Position.PersonalDetails.FurtherDetails"
etc
Unfortunately I am having terrible problems to connect all those class
modules. I created a class module, for the FurtherDetails and another
one for Personal details.
PersonalDetails would include ".Name, .Address1, .Address2, SalaryBand,
...etc"
I am using the Property Set and Get. Although the compiler agrees with
the code and autosensing recognizes the current structure as correct
when you type in the sub, at run time I am getting a very annoying
error "not valid use of property" or "invalid use of With block".
I wonder if anyone can put some light in my confusion.
TIA
FranD

Signature
Fran D
Bob Phillips - 19 Feb 2006 19:37 GMT
Is this the sort of thing you mean
>>>>>>>>> Standard code module
Sub Salaries()
Dim Secretary As clsResource
Set Secretary = New clsResource
Secretary.Lastname = "Williams"
Secretary.Firstname = "Joyce"
Secretary.SalaryBand = "Grade1"
MsgBox Secretary.Salary.GrossAnnualSalary(Secretary.SalaryBand)
End Sub
>>>>>>>> Secretary Class - named clsResource
Option Explicit
Private mSalary As clsSalary
Private mLastname As String
Private mFirstname As String
Private mSalaryBand As String
Property Get Salary() As clsSalary
Set Salary = mSalary
End Property
Property Let Lastname(pzLastname As String)
End Property
Property Let Firstname(pzFirstname As String)
End Property
Property Let SalaryBand(pzSalaryBand As String)
mSalaryBand = pzSalaryBand
End Property
Property Get SalaryBand() As String
SalaryBand = mSalaryBand
End Property
Public Function GetSalary()
GetSalary = cSalary.Salary(mSalaryBand)
End Function
Private Sub Class_Initialize()
Set mSalary = New clsSalary
End Sub
>>>>>>>> Salart Class - named clsSalary
Property Get GrossAnnualSalary(Grade As String)
Select Case Grade
Case "Grade1": GrossAnnualSalary = "$25,000"
Case "Grade2": GrossAnnualSalary = "$30,000"
Case "Grade3": GrossAnnualSalary = "$35,000"
Case Else: GrossAnnualSalary = "N/A"
End Select
End Property
--
HTH
Bob Phillips
(remove nothere from the email address if mailing direct)
> Dear All
> I am trying to develop a big class module that will include few other
[quoted text clipped - 29 lines]
> Fran D's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=28365
> View this thread: http://www.excelforum.com/showthread.php?threadid=379451
Fran D - 21 Feb 2006 22:10 GMT
Hi Bob
Thanks for your code, it´s pretty much what I am looking for and it
works wonders!
I noticed you didn´t use the Property Set at all which I presumed it
was a basic requirement. Could you please tell me when and how would
you use it?
TIA again
FranD

Signature
Fran D
Bob Phillips - 21 Feb 2006 22:49 GMT
Hi Fran
Property Set is used when declaring an object property, such as a range, as
against a string, number etc.
--
HTH
Bob Phillips
(remove nothere from the email address if mailing direct)
> Hi Bob
> Thanks for your code, it´s pretty much what I am looking for and it
[quoted text clipped - 11 lines]
> Fran D's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=28365
> View this thread: http://www.excelforum.com/showthread.php?threadid=379451
Fran D - 25 Feb 2006 13:49 GMT
Thanks again Bob. That certainly helps a lot! I appreciate your patience
with a beginner! Please keep an eye on this thread, no doubt other
questions will arise.
Regards
FranD

Signature
Fran D
Bob Phillips - 25 Feb 2006 14:29 GMT
Fran,
It might be best to open a new thread for another question, open it out
more.
--
HTH
Bob Phillips
(remove nothere from the email address if mailing direct)
> Thanks again Bob. That certainly helps a lot! I appreciate your patience
> with a beginner! Please keep an eye on this thread, no doubt other
[quoted text clipped - 7 lines]
> Fran D's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=28365
> View this thread: http://www.excelforum.com/showthread.php?threadid=379451