Get and set

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yomus

    #1

    Get and set

    hi

    Does anyone know how to use the get and set command

    thanks


  • Josip Habjan

    #2
    Re: Get and set

    Hi,

    Private _mytest As String

    Public Property MyTest() As String
    Get
    Return _mytest
    End Get
    Set(ByVal Value As String)
    _mytest = Value
    End Set
    End Property


    Regards,
    Josip Habjan, Croatia
    URL: www.habjansoftware.com



    "Yomus" <Busted5@hotmai l.com> wrote in message
    news:%23Cfz%239 paFHA.724@TK2MS FTNGP12.phx.gbl ...[color=blue]
    > hi
    >
    > Does anyone know how to use the get and set command
    >
    > thanks
    >[/color]


    Comment

    • Mythran

      #3
      Re: Get and set


      "Josip Habjan" <jhabjan@SPAM-OFF.net.hr> wrote in message
      news:d81l3j$o97 $1@magcargo.vod atel.hr...[color=blue]
      > Hi,
      >
      > Private _mytest As String
      >
      > Public Property MyTest() As String
      > Get
      > Return _mytest
      > End Get
      > Set(ByVal Value As String)
      > _mytest = Value
      > End Set
      > End Property
      >
      >
      > Regards,
      > Josip Habjan, Croatia
      > URL: www.habjansoftware.com
      >
      >
      >
      > "Yomus" <Busted5@hotmai l.com> wrote in message
      > news:%23Cfz%239 paFHA.724@TK2MS FTNGP12.phx.gbl ...[color=green]
      >> hi
      >>
      >> Does anyone know how to use the get and set command
      >>
      >> thanks
      >>[/color]
      >[/color]

      Explanation:

      The Get and Set keywords are used for properties. The "Getter" is the Get
      keyword (statement??) that should always return the value for the property.
      The "Setter" is the Set keyword (statement??) that should always set the
      value of the property. There are also instances where there would be no
      set/get. In these instances, you would use another keyword on the property,
      as described below:

      Private mUserName As String
      Private mPassword As String

      Public ReadOnly Property UserName() As String
      Get
      Return mUserName
      End Get
      End Property

      Public WriteOnly Property Password() As String
      Set
      mUserName = Value
      End Set
      End Property

      Extra Note:

      You do not need the parameter list for the Set like most programmers use.
      This extra bit is for clarity I believe but I do not use it as it means
      typing more ;)

      Set (ByVal Value As String)
      mUserName = Value
      End Set

      gets the same results as

      Set
      mUserName = Value
      End Set

      HTH,

      Mythran

      Comment

      Working...