1
2
3
5
4
2
1
3
2  这里,要读取2的与2之间的间隔该怎么做呢?
 
按上面第一位置的2与第二位置的2之间的间隔为3,继续刚开始的第二位置的2开始,与第三位置的2的间隔为2。

解决方案 »

  1.   

    Private Sub Command1_Click()
        Dim i As Integer
        Dim intCount As Integer
        Dim a As String
        Dim blnT As Boolean
        
        a = "123542132"
        
        For i = 1 To Len(a)
            If blnT Then
                intCount = intCount + 1
            End If
            If Mid(a, i, 1) = "2" Then
                blnT = True
                If intCount > 1 Then
                    Me.Print intCount - 1
                End If
                intCount = 0
            End If
        Next i
    End Sub