If you want a property to be read-only at design time, then you can check the Ambient.UserMode property. It returns False when at design time, and True when at run-time.
Dim m_vFile As Variant
Public Property Get vFile() As Variant
'// we are happy for the client to read vFile at both run
time and design time
vFile = m_vFile
End Property
Public Property Let vFile(ByVal New_vFile As Variant)
'// only allowed to set value at run time
'// raise an error if we try to set it at design time.
If Ambient.UserMode = False Then Err.Raise 382
m_vFile = New_vFile
PropertyChanged "vFile"
End Property
So, you can see that if you only want to be able to read and set a property
at design time, then you insertIf Ambient.UserMode = False Then Err.Raise 387
into both the Property Let and Property Get procedures, and likewise,
if you only want to be able to read and set a property at run time, then you
insertIf Ambient.UserMode Then Err.Raise 387
into both the Property Let and Property Get procedures.
Comments