这一窜字符 string 用N个空格隔开 如1 2 3 4 5如何把这5个数字存到数组里?

解决方案 »

  1.   

    dim a() as string
    a=split(string)
      

  2.   

    a=split(string," ")   用这个
      

  3.   

    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
      

  4.   

    刚那个string最好用str,string是标识符。
      

  5.   

    a=split(string," ")
    'a是数组,存放你的数据