探索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
总结:第三位参数代表将原字符串截成多少组字符串