Class Property Issue 
Author Message
 Class Property Issue

In VB6, if you have a property that you want to make public readable
but only writable from within you component, you would do:

  Private m_Name as String

  Public Property Get Name() As String
    Name = m_Name
  End Property

  Friend Property Let Name(Value As String)
    m_Name = Value
  End Property

How would you do this in VB.NET? My immediate reaction was "that
can't be too difficult", but in the end I had to give up! I have
seen others posting the same question on various sites, but I
haven't seen a single useful answer!

Kind regards

Mads Rosendahl Schmidt



Mon, 31 Jan 2005 02:10:27 GMT  
 Class Property Issue
You must define a new name for the property you wish to access from inside
your component only and set it as friend (i personally prefer VB6 style)

HTH

--
Corrado Cavalli
UGIdotNET - http://www.ugidotnet.org



Mon, 31 Jan 2005 02:26:48 GMT  
 Class Property Issue
Thanks Corrado!

I still find it hard to believe :) Using one name for setting a property and
another for reading
it, imagine the ugly code it will result in. Sad to find that something I
have found very useful
and used a lot suddenly isn't possible anymore. I even tried the
migration-wizard and it
simply ignored it and made the property public writable.

Cheers


Quote:
> You must define a new name for the property you wish to access from inside
> your component only and set it as friend (i personally prefer VB6 style)

> HTH

> --
> Corrado Cavalli
> UGIdotNET - http://www.ugidotnet.org



Mon, 31 Jan 2005 03:26:40 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Class Property Issue

2. Exposing Properties collection in custom classes as many MS Classes do

3. Exposing a Properties collection in custom classes as many MS Classes do

4. Properties Property for a Custom Class

5. Can a class property have properties?

6. Can a class property have properties?

7. Class design issue

8. Class inherit issues

9. Web Class Security Issues

10. Issues with calling a form within a DLL class

11. Issues with calling a form within a DLL class

12. dhRichClient3 Thread Classes Issues

 

 
Powered by phpBB® Forum Software