Diff btwn Dim x and Private x in class module?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top