Property: ReadOnly on public scope while Read-Write on friend or private scope

S

Saran

Hi,

Below is my scenario...

I want to restrict my clients to access one of my class property
in ReadOnly mode. At the same time as an author of the component i
would like to have read-write access on it.

I tried to write 'Public ReadOnly' and 'Private WriteOnly', but
didn't work.

Is there a way other than doing (i) direct variable access or (ii)
through another property/method with a different name?

Thanks,
Saran.
 
L

Larry Lard

Saran said:
Hi,

Below is my scenario...

I want to restrict my clients to access one of my class property
in ReadOnly mode. At the same time as an author of the component i
would like to have read-write access on it.

I tried to write 'Public ReadOnly' and 'Private WriteOnly', but
didn't work.

Is there a way other than doing (i) direct variable access or (ii)
through another property/method with a different name?

VB 2002/3: No
VB 2005: Yes:

Public Property Foo() As String
Get

End Get
Private Set(ByVal value As String)

End Set
End Property

Clients will not be able to Set the property.
 

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