Skip to Content
VB.NET Language in a Nutshell, Second Edition
book

VB.NET Language in a Nutshell, Second Edition

by Steven Roman PhD, Ron Petrusha, Paul Lomax
April 2002
Intermediate to advanced
688 pages
19h 51m
English
O'Reilly Media, Inc.
Content preview from VB.NET Language in a Nutshell, Second Edition

Name

Get Statement

Syntax

Get(  )
   [ statements ]
End Get
statements (optional)

Program code to be executed when the Property Get procedure is called

Description

Defines a Property Get procedure that returns a property value to the caller

Rules at a Glance

  • The Get statement can only be used within a Property...End Property construct.

  • The property value can be returned either by using the Return statement or by assigning the value to a variable whose name is the same as the property. For example:

    Public Property MyProp As String
       
       Private sSomeVar as String 
    
       Property Get(  )
          Return sSomeVar
       End Get
    ...
    End Property

    or:

    Public Property MyProp As String
       
       Private sSomeVar as String 
    
       Property Get(  )
          MyProp = sSomeVar
       End Get
    ...
    End Property
  • The value returned by a property is usually the value of a Private variable. This adheres to accepted object-oriented techniques by protecting the property value from accidental modification.

VB.NET/VB 6 Differences

The Property Get statement in VB 6 corresponds to the Get statement in VB.NET. Though the purpose and basic operation of the two constructs is identical, the syntax of the VB.NET construct is vastly simplified and more intuitive.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

VB .NET Language in a Nutshell

VB .NET Language in a Nutshell

Steven Roman PhD, Ron Petrusha, Paul Lomax

Publisher Resources

ISBN: 0596003080Supplemental ContentCatalog PageErrata