⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcard.vb

📁 通过串口发送短信的模块,采用vb.net编写
💻 VB
📖 第 1 页 / 共 2 页
字号:
            Public Overloads Function Add(ByVal Value As vTelephone) As vTelephone
                ' After you inherit the CollectionBase class, you can access an intrinsic object
                ' called InnerList that represents your collection. InnerList is of type ArrayList.
                If Value.Preferred Then
                    Dim item As vTelephone
                    For Each item In Me.InnerList
                        item.Preferred = False
                    Next
                End If
                Me.InnerList.Add(Value)
                Return Value
            End Function

            Public Overloads Function Item(ByVal Index As Integer) As vTelephone
                ' To retrieve an item from the InnerList, pass the index of that item to the .Item property.
                Return CType(Me.InnerList.Item(Index), vTelephone)
            End Function

            Public Overloads Sub Remove(ByVal Index As Integer)
                ' This Remove expects an index.
                Dim cust As vTelephone

                cust = CType(Me.InnerList.Item(Index), vTelephone)
                If Not cust Is Nothing Then
                    Me.InnerList.Remove(cust)
                End If
            End Sub

            Public Overrides Function ToString() As String
                Dim result As New System.Text.StringBuilder()
                Dim item As vTelephone
                For Each item In Me.InnerList
                    result.AppendFormat("{0}", item.ToString)
                Next
                Return result.ToString
            End Function
        End Class

        Public Class vTelephone
            Public Preferred As Boolean
            Public TelephoneNumber As String = ""
            Public Location As vLocations
            Public Type As vPhoneTypes

            Public Sub New(ByVal Number As String)
                TelephoneNumber = Number
            End Sub

            Public Sub New(ByVal Number As String, ByVal IsPreferred As Boolean)
                TelephoneNumber = Number
                Preferred = IsPreferred
            End Sub

            Public Sub New(ByVal Number As String, ByVal PhoneLocation As vLocations, ByVal PhoneType As vPhoneTypes, ByVal IsPreferred As Boolean)
                TelephoneNumber = Number
                Location = PhoneLocation
                Type = PhoneType
                Preferred = IsPreferred
            End Sub

            Public Overrides Function ToString() As String
                Dim result As New System.Text.StringBuilder()
                result.Append("TEL")
                If Preferred Then result.Append(";PREF")
                If Not IsNothing(Location) Then result.AppendFormat(";{0}", Location.ToString.ToUpper)
                If Not IsNothing(Type) Then result.AppendFormat(";{0}", Type.ToString.ToUpper)
                result.AppendFormat(":{0}{1}", TelephoneNumber, System.Environment.NewLine)
                Return result.ToString
            End Function

            Public Sub New()

            End Sub
        End Class

        Public Class vAddresss
            ' The first thing to do when building a CollectionBase class is to inherit from System.Collections.CollectionBase
            Inherits System.Collections.CollectionBase

            Public Overloads Function Add(ByVal Value As vAddress) As vAddress
                ' After you inherit the CollectionBase class, you can access an intrinsic object
                ' called InnerList that represents your collection. InnerList is of type ArrayList.
                If Value.Preferred Then
                    Dim item As vAddress
                    For Each item In Me.InnerList
                        item.Preferred = False
                    Next
                End If
                Me.InnerList.Add(Value)
                Return Value
            End Function

            Public Overloads Function Item(ByVal Index As Integer) As vAddress
                ' To retrieve an item from the InnerList, pass the index of that item to the .Item property.
                Return CType(Me.InnerList.Item(Index), vAddress)
            End Function

            Public Overloads Sub Remove(ByVal Index As Integer)
                ' This Remove expects an index.
                Dim cust As vAddress

                cust = CType(Me.InnerList.Item(Index), vAddress)
                If Not cust Is Nothing Then
                    Me.InnerList.Remove(cust)
                End If
            End Sub

            Public Overrides Function ToString() As String
                Dim result As New System.Text.StringBuilder()
                Dim item As vAddress
                For Each item In Me.InnerList
                    result.AppendFormat("{0}", item.ToString)
                Next
                Return result.ToString
            End Function
        End Class

        Public Class vAddress
            Public Preferred As Boolean
            Public AddressName As String = ""    'MS Outlook calls this Office
            Public StreetAddress As String = ""
            Public City As String = ""
            Public State As String = ""
            Public Zip As String = ""
            Public Country As String = ""
            Public AddressLabel As String = ""   'If you don't want to waste time creating this, don't and let the vCard reader format it for you
            Public Location As vLocations  'HOME, WORK, CELL
            Public Type As vAddressTypes    'PARCEL, DOM, INT

            Public Overrides Function ToString() As String
                Dim result As New System.Text.StringBuilder()

                'Write the Address
                result.Append("ADR")
                If Preferred Then result.Append(";PREF")
                If Not IsNothing(Location) Then result.AppendFormat(";{0}", Location.ToString.ToUpper)
                If Not IsNothing(Type) Then result.AppendFormat(";{0}", Type.ToString.ToUpper)
                result.AppendFormat(";ENCODING=QUOTED-PRINTABLE:;{0}", AddressName)
                result.AppendFormat(";{0}", StreetAddress.Replace(System.Environment.NewLine, "=0D=0A"))
                result.AppendFormat(";{0}", City.Replace(System.Environment.NewLine, "=0D=0A"))
                result.AppendFormat(";{0}", State.Replace(System.Environment.NewLine, "=0D=0A"))
                result.AppendFormat(";{0}", Zip.Replace(System.Environment.NewLine, "=0D=0A"))
                result.AppendFormat(";{0}", Country.Replace(System.Environment.NewLine, "=0D=0A"))
                result.Append(System.Environment.NewLine)

                'Write the Address label
                If AddressLabel.Length > 0 Then
                    result.Append("LABEL")
                    If Not IsNothing(Location) Then result.AppendFormat(";{0}", Location.ToString.ToUpper)
                    If Not IsNothing(Type) Then result.AppendFormat(";{0}", Type.ToString.ToUpper)
                    result.AppendFormat(";ENCODING=QUOTED-PRINTABLE:{0}", AddressLabel.Replace(System.Environment.NewLine, "=0D=0A"))
                End If

                Return result.ToString
            End Function
        End Class

        Public Enum vLocations
            HOME
            WORK
            CELL
        End Enum

        Public Enum vAddressTypes
            PARCEL  'Parcel post
            DOM     'Domestic
            INT     'International
        End Enum

        Public Enum vPhoneTypes
            VOICE
            FAX
            MSG
        End Enum

        Private Shared Function IsBlank(ByVal Value As String) As Boolean
            Return (IsNothing(Value) OrElse Value.Length = 0)
        End Function

        Private Shared Function IsNotBlank(ByVal Value As String) As Boolean
            Return Not IsBlank(Value)
        End Function
    End Class
End Namespace

⌨️ 快捷键说明

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