Private Sub Command1_Click() Dim strTest As String, arryStr() As String strTest = "1 2 3 4 5" arryStr = GetArry(strTest) End Sub '删除多余的空格 Private Function DeleteSpace(strDelMe As String) As String Dim strTemp As String, strOne As String Dim strRet As String Dim i As Integer If strDelMe = "" Then DeleteSpace = "" Exit Function End If strTemp = Trim(strDelMe) For i = 1 To Len(strTemp) strOne = Mid(strTemp, i, 1) If strOne <> " " Then strRet = strRet & strOne Else If Right(strRet, 1) <> " " Then strRet = strRet & strOne End If End If Next i DeleteSpace = strRet Unload Me End FunctionPrivate Function GetArry(ByVal strValue As String) Dim arryStr() As String strValue = DeleteSpace(strValue) arryStr = Split(strValue, " ") GetArry = arryStr End Function
a=split(string)
Dim strTest As String, arryStr() As String
strTest = "1 2 3 4 5"
arryStr = GetArry(strTest)
End Sub
'删除多余的空格
Private Function DeleteSpace(strDelMe As String) As String
Dim strTemp As String, strOne As String
Dim strRet As String
Dim i As Integer
If strDelMe = "" Then
DeleteSpace = ""
Exit Function
End If
strTemp = Trim(strDelMe)
For i = 1 To Len(strTemp)
strOne = Mid(strTemp, i, 1)
If strOne <> " " Then
strRet = strRet & strOne
Else
If Right(strRet, 1) <> " " Then
strRet = strRet & strOne
End If
End If
Next i
DeleteSpace = strRet
Unload Me
End FunctionPrivate Function GetArry(ByVal strValue As String)
Dim arryStr() As String
strValue = DeleteSpace(strValue)
arryStr = Split(strValue, " ")
GetArry = arryStr
End Function
'a是数组,存放你的数据