LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Dim vs. Public

"Jamie Collins" wrote in message
oups.com...

Bob Phillips wrote:

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 ...


Yes, but I did say in this way (that is the Property way). This may work,
but it is another way <vbg

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.


I agree. The dichotomy kicks in again though, as most people learning
classes, or wantintg to learn about classes, would probably not understand
such complexities. For an exercise in selling classes, I think an Excel
based example would be good. I know nothing about charting in Excel (I hate
Excel charts!), but I bet there is potential there for a good class to show
their use.

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.


The old Catch-22.

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.


Interesting. I need to email you offline on another topic, but I will
continue this a little in that as well. Can you also give the URL for that
discussion (hope it isn't the one on Ken Getz's article <ebg) so that I can
read your thoughts.


Interesting thread Jamie, thanks.




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Public Variables Jerry McNabb Excel Discussion (Misc queries) 0 February 24th 08 01:26 AM
Public Password Excel 2003 - SPB Excel Discussion (Misc queries) 2 May 23rd 07 11:08 PM
Public Function Monty Excel Discussion (Misc queries) 9 December 24th 04 06:35 PM
public sub Bob Excel Programming 3 December 10th 04 08:49 PM
Public Sub Help No Name Excel Programming 2 May 18th 04 11:09 PM


All times are GMT +1. The time now is 04:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"