Gadziu
Gadziu

Reputation: 697

Object from module sees private variable from class

I don't know if I'm doing wrong, but I think this is not normal. I have class clsPerson

Private pNameFirst As String

Public Property Get NameFirst() As String
     NameFirst = pNameFirst
End Property
Public Property Let NameFirst(sNameFirst As String)
     pNameFirst = sNameFirst
End Property

Now in Module I have procedure test

Sub test()
    Dim Person As New clsPerson

    Person.NameFirst = "test"
End Sub

When I look at Locals and unwrap Person object I can see there my private variable pNameFirst. enter image description here

Why?

Upvotes: 0

Views: 95

Answers (1)

QHarr
QHarr

Reputation: 84465

The locals window will still display your Private variables from the class. What you can't do in the module is alter the value directly of the private variable.

The locals window will show all your declared variables and ignore scope.

Edit:

See further discussion here:

Should I have to have duplicate values in VBA class objects?

Upvotes: 1

Related Questions