如果真的没有可以自己编一个- Public Function LeftStr(ByVal String1 As Variant, ByVal String2 As Variant)
- On Error Resume Next
- LeftStr = Left(String1, InStr(String1, String2) - 1)
- If Err Then LeftStr = False
- End FunctionPublic Function RightStr(ByVal String1 As Variant, ByVal String2 As Variant)
- On Error Resume Next
- RightStr = Right(String1, Len(String1) - Len(String2) - InStr(String1, String2) + 1)
- If Err Then RightStr = False
- End FunctionPublic Function MySplit(ByVal String1 As Variant, ByVal String2 As Variant)
- Dim pStr() As String
- Dim pStrs As New Collection
- Do While InStr(1, String1, String2) > 0
- pStrs.Add LeftStr(String1, String2)
- String1 = RightStr(String1, String2)
- Loop
- pStrs.Add String1
- ReDim pStr(pStrs.Count - 1)
- For i = 0 To pStrs.Count - 1
- pStr(i) = pStrs(i + 1)
- Next i
- MySplit = pStr
- End FunctionPublic Sub test()
- For Each i In MySplit("12 23 45", " ")
- MsgBox i
- Next i
- End Sub
我以前也不知道可以用Split分割,所以自己编了一个 |