Private Declare Function GetTickCount Lib "kernel32" () As LongPrivate Sub Command1_Click()
Dim i As Long
Dim s As String
Dim a() As String
Dim b() As String
Dim t As Long
Dim j As Longs = String(15 * 100000, vbNullChar)
For i = 1 To 100000
Mid(s, i * 15 - 14, 14) = "abcdefghijklmn"
Mid(s, i * 15, 1) = ","
Next
t = GetTickCount
a = Split(s, ",")
t = GetTickCount - t
Debug.Print "split耗费时间:" & t
s = vbNullStrings = String(14 * 100000, vbNullChar)
For i = 1 To 100000
Mid(s, i * 14 - 13, 14) = "abcdefghijklmn"
Next
t = GetTickCount
j = Len(s)
ReDim b(j - 1) As String
For i = 0 To j - 1
b(i) = Mid(s, i * 14 + 1, 14)
NextDim c As Bytet = GetTickCount - t
Debug.Print "自定义耗费时间:" & t
End Sub
Dim i As Long
Dim s As String
Dim a() As String
Dim b() As String
Dim t As Long
Dim j As Longs = String(15 * 100000, vbNullChar)
For i = 1 To 100000
Mid(s, i * 15 - 14, 14) = "abcdefghijklmn"
Mid(s, i * 15, 1) = ","
Next
t = GetTickCount
a = Split(s, ",")
t = GetTickCount - t
Debug.Print "split耗费时间:" & t
s = vbNullStrings = String(14 * 100000, vbNullChar)
For i = 1 To 100000
Mid(s, i * 14 - 13, 14) = "abcdefghijklmn"
Next
t = GetTickCount
j = Len(s)
ReDim b(j - 1) As String
For i = 0 To j - 1
b(i) = Mid(s, i * 14 + 1, 14)
NextDim c As Bytet = GetTickCount - t
Debug.Print "自定义耗费时间:" & t
End Sub
如果我的字符串是有规律的,假如10个为一组的分割的话,split就不能用了.
当然也可以用正则,但那个未必效率就佳
只是数组赋值
而查找分割符的代码没有
其他要找到再赋值吧