contact.vb

来自「Mastering VBNet Include Source Code」· VB 代码 · 共 117 行

VB
117
字号
<Serializable()> Public Class Contact
    Private _companyName As String
    Private _contactName As String
    Private _address1 As String
    Private _address2 As String
    Private _city As String
    Private _state As String
    Private _zip As String
    Private _tel As String
    Private _email As String
    Private _URL As String

    Property CompanyName() As String
        Get
            CompanyName = _companyName
        End Get
        Set(ByVal Value As String)
            If Value Is Nothing Or Value = "" Then
                Throw New Exception("Company Name field can't be empty")
                Exit Property
            End If
            _companyName = Value
        End Set
    End Property

    Property ContactName() As String
        Get
            ContactName = _contactName
        End Get
        Set(ByVal Value As String)
            _contactName = Value
        End Set
    End Property

    Property Address1() As String
        Get
            Address1 = _address1
        End Get
        Set(ByVal Value As String)
            _address1 = Value
        End Set
    End Property

    Property Address2() As String
        Get
            Address2 = _address1
        End Get
        Set(ByVal Value As String)
            _address2 = Value
        End Set
    End Property

    Property City() As String
        Get
            City = _city
        End Get
        Set(ByVal Value As String)
            _city = Value
        End Set
    End Property

    Property State() As String
        Get
            State = _state
        End Get
        Set(ByVal Value As String)
            _state = Value
        End Set
    End Property

    Property ZIP() As String
        Get
            ZIP = _zip
        End Get
        Set(ByVal Value As String)
            _zip = Value
        End Set
    End Property

    Property tel() As String
        Get
            tel = _tel
        End Get
        Set(ByVal Value As String)
            _tel = Value
        End Set
    End Property

    Property EMail() As String
        Get
            EMail = _email
        End Get
        Set(ByVal Value As String)
            _email = Value
        End Set
    End Property

    Property URL() As String
        Get
            URL = _URL
        End Get
        Set(ByVal Value As String)
            _URL = Value
        End Set
    End Property

    Overrides Function ToString() As String
        If _contactName = "" Then
            Return _companyName
        Else
            Return _companyName & vbTab & "(" & _contactName & ")"
        End If
    End Function

End Class

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?