Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Diff btwn Dim x and Private x in class module?

0 views
Skip to first unread message

joeu2004

unread,
May 24, 2011, 7:21:26 PM5/24/11
to
Walkenbach uses examples of Dim x and Private x for non-public
variables in a class module.

Is there any semantic difference?

I cannot see any. For example:

myTest class module:

Dim xCnt As Long
Private xIdx As Long

Private Sub Class_Initialize()
xCnt = xCnt + 1
MsgBox xCnt
End Sub

Property Get cnt()
cnt = xCnt
End Property

Property Let idx(x As Long)
xIdx = x
End Property

Property Get idx() As Long
idx = xIdx
End Property

-----

regular module:

Sub testit()
Dim a As myTest, b As myTest
Set a = New myTest
MsgBox a.idx & " " & a.cnt 'initial values
a.idx = 2
MsgBox a.idx & " " & a.cnt 'changed values
Set b = New myTest
MsgBox b.idx & " " & b.cnt 'initial values
End Sub

0 new messages