Your full service technology partner! 
-Collapse +Expand
Search VB.Net Group:

-Collapse +Expand VB.Net To/From
-Collapse +Expand VB.Net Store

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingVB.NetOOP   Print This    All Groups  
  From the October 2015 Issue of Prestwood eMag
VB.Net Member Property (property, get, set)
Posted 13 years ago on 12/20/2008 and updated 1/28/2009
VB.Net Code Snippet:
 A flashcard from our VB.Net Flashcards Library
 A code snippet from our VB.Net Code Snippets Page


VB.Net Member Property

VB.Net uses a special property keyword along with special get and set methods to both get and set the values of properties. For a read-only property, leave out the set method. The value keyword is used to refer to the member field. Properties can make use of any of the access modifiers (private, protected, etc).

My preference for VB.Net code is to start member fields with "F" ("FName" in our example) and drop the "F" with properties that manage member fields ("Name" in our example).

Syntax Example:
Public Class Cyborg
Private FCyborgName As String
  Public Property CyborgName()
Return F
End Get
Set(ByVal value)
CyborgName = value
End Set
End Property
End Class

Complete Example

Refer to our VB.Net Class..Object post for an example.

Rumor Mill: Auto-Implemented Properties in VB.Net 10.0

It is widely rumored that the next version of VB.Net will include auto-implemented properties. Currently C# 3.0 and later offer this feature as follows:

//C# auto-implemented property.
pulic int VendorID {get; set;}

The next version of VB.Net is rumored to offer a similar syntax feature:

'VB.Net auto-implemented property.
Public Property VendorID() As Integer 

In addition, it is rumored that the next version will allow you to iniatilize the property which is something C# does not allow.

'Initialized auto-implemented properity.
Public Property VendorID() As Integer = -1

This is important and useful when no additional logic is required for a property. Soon properties will be just as easy to create as a member field and have an equivalent compact form (a single line of code).

More Info

Code:  VB.Net Class..Object (Class..End Class..New)


Share a thought or comment...
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1156A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

 KB Article #101741 Counter
Since 12/20/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site:

©1995-2021 Prestwood IT Solutions.   [Security & Privacy]