VBHTMLInstr

Searches for string in readable text from HTMLBlock.
So it will not find what is inside tags, only what is outside tags, exactly what you are seeing in produced web page.
Returns exact true location of found string considering full HTML block

CodeFunctionName
What is this?

Public

Tested

Original Work
Function VBHTMLInstr(SearchFor, SearchInHTML, Optional StartSearch = 1, Optional SearchCompare = vbTextCompare)
    ' Finds the location of 1st string found inside HTML block
    ' Making sure that string was found not as tag inside list of tags, but rather as full body string inside that HTML block
    ' VBInstr = InStr(StartSearch, SearchIn, SearchFor, SearchCompare)
    '
    Rett = 0
    Str1 = " >"
    Str2 = " <"
    StartFrom = StartSearch
    Find1 = VBInstr(Str1, SearchInHTML, StartFrom)
    Find2 = VBInstr(Str2, SearchInHTML, Find1 + 1)
    If Find1 = 0 Or Find2 = 0 Then ' No HTML found, return regular search in string
        Rett = VBInstr(SearchFor, SearchInHTML, StartSearch, SearchCompare)
        GoTo ByeBye
    End If
    Do Until StartFrom > Len(SearchInHTML)
        Find1 = VBInstr(Str1, SearchInHTML, StartFrom) ' Find next >
        Find2 = VBInstr(Str2, SearchInHTML, Find1 + 1) ' Find next < that is after >
        Find3 = VBInstr(Str1, SearchInHTML, Find1 + 1) ' Find next > that is after >
        ' Go next if we found > after > before <
        If Find3 > Find2 Then
            Find4 = VBInstr(SearchFor, SearchInHTML, Find1, SearchCompare)
            If Find4 > 0 And Find4 > Find1 And Find4 < Find2 Then ' IF number we found is between > and <
                Rett = Find4
                Exit Do
            End If
        End If
        StartFrom = Find1 + 1
    Loop
ByeBye:
    VBHTMLInstr = Rett
End Function

earchFor, SearchInHTML, Optional StartSearch = 1, Optional SearchCompare = vbTextCompare

Views 239

Downloads 59

CodeID
DB ID