探索Split函数第三位参数的用法

Private Sub Form_Click()
    Dim c() As String
    c = Split("A,B,C,D,E", ",")
    For i = 0 To UBound(c)
        Print c(i)
    Next i
End Sub

运行效果:
A

B

C

D

E

Private Sub Form_Click()
    Dim c() As String
    c = Split("A,B,C,D,E", ",", 1)
    For i = 0 To UBound(c)
        Print c(i)
    Next i
End Sub

运行效果:

A,B,C,D,E

Private Sub Form_Click()
    Dim c() As String
    c = Split("A,B,C,D,E", ",",2)
    For i = 0 To UBound(c)
        Print c(i)
    Next i
End Sub

运行效果:
A

B,C,D,E

Private Sub Form_Click()
    Dim c() As String
    c = Split("A,B,C,D,E", ",", 3)
    For i = 0 To UBound(c)
        Print c(i)
    Next i
End Sub

运行效果:

A

B

C,D,E

总结:第三位参数代表将原字符串截成多少组字符串

posted @ 2014-07-24 08:56  Spacecup  阅读(525)  评论(1编辑  收藏  举报