有一字符串:  01020305061213151617.............
现在要求取出其中的时序列的一段组成数组如:010203 为一组,030506为一组,1213为一组............
要求函数,输出为数组.
急求..

解决方案 »

  1.   

    位数固定吗?如果固定的话可以用MID函数进行拆分~~
      

  2.   

    Mid 函数返回 Variant (String),其中包含字符串中指定数量的字符。语法Mid(string, start[, length])Mid 函数的语法具有下面的命名参数:部分 说明
    string 必要参数。字符串表达式,从中返回字符。如果 string 包含 Null,将返回 Null。
    start 必要参数。为 Long。string 中被取出部分的字符位置。如果 start 超过 string 的字符数,Mid 返回零长度字符串 ("")。
    length 可选参数;为 Variant (Long)。要返回的字符数。如果省略或 length 超过文本的字符数(包括 start 处的字符),将返回字符串中从 start 到尾端的所有字符。
    说明欲知 string 的字符数,可用 Len 函数。注意   MidB 函数作用于字符串中包含的字节数据。因此其参数指定的是字节数,而不是字符数。
      

  3.   

    本示例使用 Mid 语句来得到某个字符串中的几个字符。Dim MyString, FirstWord, LastWord, MidWords
    MyString = "Mid Function Demo" 建立一个字符串。
    FirstWord = Mid(MyString, 1, 3) ' 返回 "Mid"。
    LastWord = Mid(MyString, 14, 4) ' 返回 "Demo"。
    MidWords = Mid(MyString, 5) ' 返回 "Funcion Demo"。
      

  4.   

    现在是我不知道MID函数的参数值啊.
    那要通过比较才知道啊.可是这个算法是????
      

  5.   

    如果只是取得递增数值的话,可以用for函数,每次去两个(01 02算是两个)然后比较如果是递增就先存到一个临时变量里,否则,说明这个递增已经结束,进行处理然后从继续提取下个递增数
      

  6.   

    Option Explicit
    Const Def_Value As String = "010203050612131516172223242526278"Dim ResultArr() As String
    Dim i As Integer, j As IntegerPrivate Sub Form_Load()
        Call GetValue(Def_Value)
    End SubPublic Function GetValue(ByVal sValue As String)
        ReDim ResultArr(0) As String
        
        Dim s As String
        Dim tmpArrIndex As Integer
        tmpArrIndex = IIf(Len(sValue) Mod 2 > 0, Len(sValue) Mod 2 + 1, Len(sValue) Mod 2)
        
        If tmpArrIndex > 0 Then _
            sValue = Left$(sValue, Len(sValue) - 1)
            
        For i = 1 To Len(sValue) - 1 Step 2
            Dim tmp1, tmp2
            tmp1 = Val(Mid(Mid(sValue, i), 1, 2)) + 1
            tmp2 = Val(Mid(Mid(sValue, i), 3, 2))
            
            If tmp1 = tmp2 Then
                ReDim Preserve ResultArr(0 To UBound(ResultArr) + 1) As String
                ResultArr(UBound(ResultArr) - 1) = Mid(Mid(sValue, i), 1, 2)
                ResultArr(UBound(ResultArr)) = Mid(Mid(sValue, i), 3, 2)
            Else
                On Error Resume Next
                For j = 0 To UBound(ResultArr)
                    s = s + ResultArr(j)
                Next
                Debug.Print s
                Debug.Print ""
                
                ReDim ResultArr(0) As String
                s = ""
            End If
            
            DoEvents
        Next
    End Function
      

  7.   

    我给你一个简单的!
    Private Sub GetValue(ByVal strV As String, arrValue() As String)
        Dim strT1 As String, strT2 As String
        Dim strTmpValue As String
        Dim lLen As Long
        Dim I As Long
        
        lLen = Len(strV)
        
        For I = 1 To lLen Step 2
            strT2 = Mid(strV, I, 2)
            Me.List2.AddItem strT2
            If strT1 <> "" Then
                If Val(strT2) - Val(strT1) = 1 Then
                    strTmpValue = strTmpValue & strT2
                Else
                    strTmpValue = strTmpValue & "|" & strT2
                End If
                strT1 = strT2
            Else
                strTmpValue = strT2
                strT1 = strT2
            End If
        Next I
        
        arrValue = Split(strTmpValue, "|")
    End Sub
      

  8.   

    笔误!语句:Me.List2.AddItem strT2 应删除!
      

  9.   

    sub GetArrey(strtemp as string)
        dim i as integer
        dim tstr as string
        for i=1 to len(strtemp) step 6             tstr=mid(strtemp,i,6)
                 if len(tstr)=6 then
                      if val(right(tstr,2))-val(mid(tstr,3,2)=1 AND val(mid(tstr,3,2))-val(left(tstr,2))=1 then
                       debug.print tstr
                 end if
        next i
    end sub
      

  10.   

    sub GetArrey(strtemp as string)
        dim i as integer
        dim tstr as string
        for i=1 to len(strtemp)
                 tstr=mid(strtemp,i,6)
                 if len(tstr)=6 then
                      if val(right(tstr,2))-val(mid(tstr,3,2)=1 AND val(mid(tstr,3,2))-val(left(tstr,2))=1 then
                       debug.print tstr
                 end if
        next i
    end sub
      

  11.   

    wfnuser(夏雪)兄,数据长度不是固定的!
      

  12.   

    Dim str      As String
    Dim aa()     As String
    Dim lngTmp   As Long
    Dim lngTemp  As Long
    Dim strString As String
    Dim str1 As String
    Dim i    As Long
         str = "01020312130105"
         lngTmp = CLng(Left(str, 2))
         str1 = Left(str, 2)
         Do Until False
            str = Right(str, Len(str) - 2)
            If Len(str) < 1 Then Exit Do
            lngTemp = CLng(Left(str, 2))
            If lngTmp > lngTemp Then
                str1 = str1 & "-"
                lngTmp = lngTemp
                 str1 = str1 & Left(str, 2)
            Else
                lngTmp = lngTemp
                str1 = str1 & Left(str, 2)
            End If
        Loop
        aa = Split(str1, "-")
      

  13.   

    Rick110AAA(海牛) and  NotReady(No)   的代码可行
    ------------------谢谢
    其实这是我们大学时期的数据结构中一个很具有代表意义的算法。
    现在怀念读书啊。
    ---------
    结帖