mshflexgrid 的一个列中有 “01,02,03,08,07,05,04”, 在 " 04,05,03,08" 之中第一次出现的位置呢 运行结果第一次出现的位置和数据是03 。表达式什么函数来表达呢

解决方案 »

  1.   

      搜索字符串如果一个,我能做到 print mid("“01,02,03,08,07,05,04",instr(1,“01,02,03,08,07,05,04","03"))  如果," 04,05,03,08" 用这么多的字符串来比较时,不知道什么函数来表达。
      

  2.   

    Private Sub Command1_Click()
        Dim str1 As String
        Dim str2 As String
        Dim strA() As String
        Dim i As Integer
        Dim j As Integer
        Dim blnJ As Boolean
        
        str1 = "01,02,03,08,07,05,04"
        str2 = "04,05,03,08"
        
        strA = Split(str2, ",")
        
        For i = 1 To Len(str1)
            For j = 0 To UBound(strA) - 1
                If Mid(str1, i, 2) = strA(j) Then
                    MsgBox strA(j) & "在" & i
                    blnJ = True
                    Exit For
                End If
            Next j
            If blnJ Then Exit For
        Next i
        
            
            
    End Sub
      

  3.   

     
    Dim intPosition As Integer
    Dim strData As String
    Dim intMinLength As Integer
    Dim strSource1 As String
    Dim strSource2 As String
    Dim i As IntegerstrSource1="01,02,03,08,07,05,04"'//你可以用一个循环把mshflexgrid指定列读出来,比如读第二列:
                                           '//For i = 0 To mshflexgrid1.Rows
                                          '//    strSource1=strSource1 & mshflexgrid1.TextMatrix(i,1) & ","
                                          '// Next
    strSource2="04,05,03,08"If Ubound(Split(strSource1,","))>Ubound(Split(strSource2,",")) Then
        intMinLength=Ubound(Split(strSource2,","))
    Else
        intMinLength=Ubound(Split(strSource1,","))
    End IfFor i=0 To intMinLength
        If Split(strSource1,",")(i)=Split(strSource2,",")(i) Then
            intPosition=i
            strData=Split(strSource1,",")(i)
            Exit For
        End If
    Next 
      

  4.   

    Option ExplicitPrivate Sub Form_Load()
     Dim Text As String
     Dim FindText As String
     Text = "01,02,03,08,07,05,04"
     FindText = "04,05,03,08"
     
     Dim Arr() As String
     
     Dim cArr() As Long
     
     Arr = Split(FindText, ",")
     
     ReDim cArr(UBound(Arr)) As Long
     
     Dim i As Long
     
     For i = 0 To UBound(Arr)
      
        cArr(i) = InStr(1, Text, Arr(i))
        'MsgBox cArr(i)
        
     Next
     
     Dim Index As Long
     Dim Bak As Long
     Bak = cArr(0)
     Index = 0
     For i = 0 To UBound(cArr)
        If Bak > CLng(cArr(i)) Then
           Bak = cArr(i)
           Index = i
        End If
     Next MsgBox Arr(Index)
     
    End Sub
      

  5.   

    对了,上面intPosition=i+1