Introduction to Class Programming

Write-only property

This kind of property is nearly the most perplex property that Visual Basic has to offer.  Because you cannot find anything useful for this property.  And usually, programmer find it  as unnatural of using this kind of property.  For completeness, write-only property can be implemented by omitting the corresponding Property Get.  A classical example is a Password property in a secured application usually with Login features.  You can assign and validate the login process of the user, but your user cannot read it, because it compromise the security of the your application.

Private m_Password As String

Property Let Password(ByVal strNewValue As String)
    ' Raise error if password in invalid
    ' .. code omitted..
    ' Else assign to member variable.
    m_Password = strNewValue 
End Property

Frequently, programmer prefer to create a method that accept the value as an argument, if the circumstances occurs like for our example. 

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth