J
joeu2004
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
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