aaa=".........<font color=red>我要获取这段文字</font>...."如何获取<font color=red> 和 </font>中间这段中文?
中文字不是固定的, <font color=red> 和 </font>是固定不变的

解决方案 »

  1.   

    aaa = ".........<font color=red>我要获取这段文字</font>...."
    bbb = "<font color=red>"
    ccc = "</font>"
    a = InStr(1, aaa, bbb)
    b = InStr(a, aaa, ccc)
    MsgBox Mid(aaa, (a + Len(bbb)), (b - (a + Len(bbb))))
      

  2.   

    封装了一个函数:
    Private Function findstr(ByVal word1 As String, ByVal word2 As String, ByVal finds As String) As String
        Dim i As Long, j As Long
        i = Len(word1)
        If i = 0 Then
            Exit Function
            findstr = ""
        ElseIf i > Len(finds) Then
            Exit Function
            findstr = ""
        End If
        j = Len(word2)
        If j = 0 Then
            Exit Function
            findstr = ""
        ElseIf j > Len(finds) Then
            Exit Function
            findstr = ""
        End If
        Dim num1 As Long, num2 As Long
        num1 = InStr(1, finds, word1)
        If num1 = 0 Then
            Exit Function
            findstr = ""
        End If
        num2 = InStr(num1, finds, word2)
        If num2 = 0 Then
            Exit Function
            findstr = ""
        End If
        Dim findlength As Long
        findlength = num2 - num1 + Len(word2)
        findstr = Mid(finds, num1, findlength)
        
    End Function
      

  3.   

    抱歉,上面的有误,更正:
    Private Function findstr(ByVal word1 As String, ByVal word2 As String, ByVal finds As String) As String
        Dim i As Long, j As Long
        i = Len(word1)
        If i = 0 Then
            Exit Function
            findstr = ""
        ElseIf i > Len(finds) Then
            Exit Function
            findstr = ""
        End If
        j = Len(word2)
        If j = 0 Then
            Exit Function
            findstr = ""
        ElseIf j > Len(finds) Then
            Exit Function
            findstr = ""
        End If
        Dim num1 As Long, num2 As Long
        num1 = InStr(1, finds, word1)
        If num1 = 0 Then
            Exit Function
            findstr = ""
        End If
        num2 = InStr(num1, finds, word2)
        If num2 = 0 Then
            Exit Function
            findstr = ""
        End If
        Dim findlength As Long
        findlength = num2 - num1 - Len(word1)
        findstr = Mid(finds, num1 + Len(word1), findlength)
        
    End Function
      

  4.   

    findstr怎么用? 提供什么参数?
      

  5.   

    更正一下问题,
    aaa="....</font>.......<font color=red>我要获取这段文字</font>...</font>.."如何获取<font color=red> 和 </font>中间这段中文?
    中文字不是固定的, <font color=red> 和 </font>是固定不变的前后文中多次出现</font>的