VB. NET and other attributes

Source: Internet
Author: User

There are three examples

  1. Public   Property Rank () As   String   ' Note that the attribute name is enclosed in parentheses.
    Get
    Return Strpos
    End   Get
    Set ( Byval Value As   String )
    Strpos = Value
    End   Set
    End Property

     

  2. Public   Readonly   Property Fig () As   String ' Readonly must be before Property
    Get
    Dim I As   Integer
    Dim S As   String
    S =   Join (Strholobby, " , " ) ' This function is used to connect strings in the array.
    Return S
    End   Get
    End Property

     
    3,

    ' This is the index definition tool!
    Public   Readonly   Property Indexholobby ( Byval Index As   Integer ) As   String
    Get
    If (Strholobby Is   Nothing ) Or (Index >   Ubound (Strholobby )) Then
    ' Have you noticed the above ubound? And lbound ()!
    ' Their namespace is Microsoft. VisualBasic.
    Return   Nothing
    End   If
    Return Strholobby (INDEX)
    End   Get
    End Property

    4,

    Public   Writeonly   Property Whobby () As   String
    Set ( Byval Value As   String )
    If Value Is   Nothing   Then
    If   Not (Strholobby Is   Nothing ) And Strholobby. getlength ( 0 ) >   1   Then
    Redim   Preserve Strholobby ( Ubound (Strholobby) -   1 )
    End   If
    Else
    If Strholobby Is   Nothing   Then
    Redim Strholobby ( 0 )
    Else
    Redim   Preserve Strholobby ( Ubound (Strholobby) +   1 )
    End   If
    Strholobby ( Ubound (Strholobby )) = Value
    End   If
    End   Set
    End Property

    5,

    Default   Public   Property Words ( Byval Index As   Integer ) As   String ' Note default
    Get' have you noticed the parameter? When using this attribute, it is the same as implementing the indexer. <Classobj (INDEX)>
    Words = Thewords (INDEX)
    End   Get
    Set ( Byval Value As   String )
    Thewords (INDEX) = Value
    End   Set
    End Property

     

     

     

     

     

     

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.