HTML_InsideTag_ByIndex

Checks if LocIndex is found between open and close of HTMLTag or between close and open of the tag inside a large string like HTML code of a page.
Returns number:
1: If LocIndex is between open and close (as in between < td ...> and < /td ...>)
2: If LocIndex is between close and open instead (as in between < /td ...> and < td ...>)
0: anything else
It will also return the location of the tag that was found before LocIndex if Return was 1 or 2
Will also return the location of the start at left end inside ReturnLocation variable

Similar to Between_HTMLtag but this one does not search, it instead needs the actual character location LocIndex to start searching from.

CodeFunctionName
What is this?

Public

Tested

Original Work
Function HTML_InsideTag_ByIndex(LocIndex, Page7, Optional HTMLTag = "td:", Optional ByRef ReturnLocation)
    ' used to be called Between_HTMLtag_ByIndex
    ' Returns number
    ' 1: If LocIndex is between < td: ... > and < /td: ... >
    ' 2: If LocIndex is between < /td: ... > and < td: ... >
    ' 0: anything else
    '    Will also return the location of the start at left end inside ReturnLocation variable
    Rett = 0
    If LocIndex = 0 Then GoTo ByeBye
    Found1 = 0 ' Found1 either 0, -1 or I = location of open tag < td
    Found2 = 0 ' Found2 either 0, -1 or J = location of closed tag < /td
    HTMLOpen = " <" & HTMLTag
    HTMLClose = " </" & HTMLTag
    For I = LocIndex To 1 Step -1
        If UCase(Mid(Page7, I, Len(HTMLOpen))) = UCase(HTMLOpen) Then            ' Found open before we find close
            Found1 = I
            Exit For
        ElseIf UCase(Mid(Page7, I, Len(HTMLClose))) = UCase(HTMLClose) Then    ' Found close before Open
            Found1 = -1
            Exit For
        End If
    Next
    For J = LocIndex To Len(Page7)
        If UCase(Mid(Page7, J, Len(HTMLOpen))) = UCase(HTMLOpen) Then            ' Found open before we find close
            Found2 = -1
            Exit For
        ElseIf UCase(Mid(Page7, J, Len(HTMLClose))) = UCase(HTMLClose) Then    ' Found close before Open
            Found2 = J
            Exit For
        End If
    Next
    If Found1 > 0 And Found2 > 0 Then
        Rett = 1
        ReturnLocation = I ' LocIndex
    ElseIf Found1 < 0 And Found2 < 0 Then
        Rett = 2
        ReturnLocation = J ' LocIndex
    End If
ByeBye:
    HTML_InsideTag_ByIndex = Rett
End Function

LocIndex, Page7, Optional HTMLTag = "ix:", Optional ByRef ReturnLocation

Views 598

Downloads 38

CodeID
DB ID