This is the most valuable part of my code, hehe. Ok, for the sake of learning/teaching, here it is...
Function MyText(ByVal strText as string,ByVal strStarttag as string, ByVal strEndTag as string) as string
Dim intStart
Dim intend
Dim LenstrStartTag As Long
Dim LenstrEndTag As Long
Dim LenstrText As Long
Dim txtTmp1 As String
Dim txttmp2 As String
Dim txtDataLen As Long
Dim TxTData As String
Dim txttmp4 As String
Dim txttmp3 As String
Dim Inttmp1 As Long
Dim Inttmp2 As Long
Dim x As Integer
On Error Resume Next
Trim (strText)
LenstrText = Len(strText)
LenstrStartTag = Len(strStarttag)
LenstrEndTag = Len(strEndTag)
intStart = InStr(1, strText, strStarttag, vbTextCompare)
intStart = intStart + LenstrStartTag
intend = InStr(intStart + 1, strText, strEndTag, vbTextCompare)
txttmp2 = Mid(strText, intStart, intend - intStart - 1) & vbCrLf
txttmp3 = Mid(txttmp2, 1, 13)
'If txttmp3 = "
Then
If txttmp3 = "href=" & Chr(34) & "
Then
SrchIt (txttmp2) '***This is where I want to search to see if the link is already there.
AddRec2 (txttmp2) 'Here is where the link is added to the Datagrid
MyText = MyText & txttmp2
txttmp3 = vbNullString
Else
txttmp3 = vbNullString
End If
Do Until intStart >= LenstrText
DoEvents
On Error Resume Next
intStart = intend
intStart = InStr(intStart, strText, strStarttag, vbTextCompare)
intend = InStr(intStart + 1, strText, strEndTag, vbTextCompare)
If intStart = 0 Then
intStart = 1
Exit Function
End If
txtTmp1 = Trim(Mid(strText, intStart, intend - intStart)) & vbCrLf
txttmp3 = Mid(txtTmp1, 1, 13)
'If txttmp3 = "
Then
If txttmp3 = "href=" & Chr(34) & "
Then
txtDataLen = Len(Trim(txtTmp1))
TxTData = Mid(txtTmp1, 7, txtDataLen)
SrchIt (txttmp2)
AddRec2 (TxTData)
MyText = MyText & TxTData
txttmp3 = vbNullString
'ElseIf txttmp3 = "
Then
ElseIf txttmp3 = "HREF=" & Chr(34) & "
Then
txtDataLen = Len(Trim(txtTmp1))
TxTData = Mid(txtTmp1, 7, txtDataLen)
SrchIt (txttmp2)
AddRec2 (TxTData)
MyText = MyText & TxTData
txttmp3 = vbNullString
txttmp3 = vbNullString
End If
Loop
End Function
To call it I use this...
Hrefs = MyText(TmpPage, "href=" & Chr(34) & "
Chr(34) & ">")
Where TmpPage is the webpage source
"href=" & Chr(34) & "
is the starting string to search for
and
Chr(34) & ">" is the ending string
My function then returns the string between the two strings.
I want to also note that the reason I require the parsed text back to the program is because I have not yet set up the code to grab the first record of Datagrid2 as of yet. So currently, the links are saved to a txt file where they are later retrieved. I am sure you can understand why I want to get away from this method and make everything Database dependant. Anyway, Thank you for your time. I wait in anticipation...
LF
"As far as the laws of mathematics refer to reality, they are not certain; as far as they are certain, they do not refer to reality."--Albert Einstein