如何创建一个将字符串拆分成不同电子邮件的循环?

时间:2015-01-13 16:42:47

标签: vb.net

这是非常自我解释的。我想将Cc分成电子邮件使用;作为一个指标。我现在的代码如下:

Dim sEmailAddress As String



                Dim iPos As Integer
                iPos = InStr(Me.Cc, ";") ' Looks in the first parameter for the second parameter and returns the position of the first occurance of the second parameter. If there is no occurrance of the second parameter then 0 will be returned
                ' 
                Dim iLen As Integer
                iLen = Len(Me.Cc) ' iLen will = then length of me.CC - for example if me.cc = "Hello World", iLen = 11

                '
                Dim sPart As String
                sPart = Left(Me.Cc, 10) ' Returns the first 10 characters from Me.CC - for example if Me.CC = "Hello World", sPart = "Hello Wor"
                '
                Dim sPart2 As String
                sPart2 = Right(Me.Cc, 4) ' Returns the right most 4 characters from Me.CC, for example if me.CC = "Hello World", sPart2 = "orld"
                '
                Dim sPart3 As String
                sPart3 = Mid(Me.Cc, 6, 2) ' Returns 2 characters starting at position 6 from Me.CC, for example if me.cc = "Hello World", sPart3 = " W"

                Do While 


                    ' get email address
                    oNetworxEmail.AddToAddress(sEmailAddress)
                Loop
                If  Then
                    ' get email address
                    oNetworxEmail.AddToAddress(sEmailAddress)
                End If

1 个答案:

答案 0 :(得分:0)

如果你想这样做,那就太麻烦了。 String.split是一种更好的方法。

Dim splitArray() As String = String.Split(Me.Cc, ";")