Bob said:
The thing you cannot do is share a variable between modules in this
way
It is possible e.g. this in (standard) Module1:
Option Explicit
Private m_strName As String
' Name can only be set internally
Private Function SetName( _
ByVal NewName As String _
) As Boolean
m_strName = NewName
End Function
' Name can be read externally
Public Property Get Name() As String
Name = m_strName
End Property
Then this another standard module:
Sub test()
MsgBox Module1.Name
End Sub
But ...
they are not classes. I guess Jamie would not build his app this way, he
would again use a class
.... Correct! I think using Properties probably makes more sense in a
OOP (i.e. Class modules etc) model.
What we need in the public domain is a realistic
example to show their value, not the dull old employee example.
Excellent idea <vbg>. For me the examples which sink ActiveX events
helped me most when trying to get my head around classes because, as
you say, the value is immediately apparent. Also, the ones that
encapsulate seemingly nasty APIs e.g. Stephen Bullen's CFormChanger and
FormFun demo is still the ultimate for me. The paradox seems to be that
one needs to know what a class is for before it can seen as a real
solution but there's no incentive to learn until one has a suitable
problem.
Userforms, Worksheets, and ThisWorkbook are just classes. Special cases of a
class
I've often tried to start a discussion on what exactly ThisWorkbook is
(last time I tried I think I caused offence - must be a sensitive issue
<g>). Is it a class, an instance of a class, an interface, ...? It is
quite unlike any class I can write using class modules. I know I like
it because I can add new members (properties and methods) to
ThisWorkbook and so I use for things deemed to be workbook level i.e. a
lot.
Wow, I wish I could make statement like that!
I did use one the other day in an interface class (i.e. one containing
only Public declarations to be implemented in another class using
Implements), but later realized I wasn't getting a public variable at
all, just the Public Property Get/Set pair for which I'd need a Private
variable in the implementing class anyhow, so I explicitly changed it
to a Public Property Get/Set.
Jamie.
--