实用函数栏目也有一个适用于VB5的Split自定义函数:
- Public Function Split(Str As String, Delim As String) As Variant
- Dim tokens() As String, pos As Long, i As Integer
- pos = InStr(1, Str, Delim, vbTextCompare)
- i = 0
- Do While pos > 0
- ReDim Preserve tokens(0 To i)
- tokens(i) = Mid$(Str, 1, pos - 1)
- If tokens(i) = Delim Then tokens(i) = ""
- Str = Mid$(Str, pos + Len(Delim))
- i = i + 1
- pos = InStr(1, Str, Delim, vbTextCompare)
- Loop
- If Len(Str) > 0 Then
- ReDim Preserve tokens(0 To i)
- tokens(i) = Str
- End If
- Split = tokens
- End Function
|