malibog_ka_ba2003 Level: Trainee
 Registered: 01-03-2005 Posts: 2
|
Find Text in TextBox with HTML Source String Ignoring HTML tags
Dim L As Integer, R As Integer, Start As Integer
Dim FindText As String, ReplaceText As String
Start = 1
Text1.SetFocus
L = InStr(1, Text1.Text, "<", 3)
R = InStr(1, Text1.Text, ">", 3)
Do While R > 0
R = InStr(Start, Text1.Text, ">", 3) 'start searching at the end of <HTML">" and save the position
DoEvents
Do While L > 0
L = InStr(R, Text1.Text, "<", 3) - 1 'save position of "<"
If L < R Then Exit Do 'end of text
Text1.SelStart = R 'The cursor is in between ><
Text1.SelLength = (L - R) 'Highlight the text in between HTML >< tags
'=================================================================
' In this section the code will loop through the highlighted text
' and find the needed text and replace it if found. I can start at
' position R but I don't know how to stop at position L.
' I'm totally trap in this section. I NEED HELP IN THIS SECTION!
'
' Do While InStr(R, Text1.Text, Text2.text, 3) > 0 'Loop through Highlighted text
' 'Replaced found text if any
' 'If no text has found the InStr(R, Text1.Text, Text2.text, 3) will
' 'return the next nearest match outside the Highlighted text
' 'I want to Exit Do if no Text2.text match
' Loop
'
'=================================================================
Start = R + 1 'start searching in the most recent position or after Highlighted text
DoEvents
Sleep (1500)
Exit Do
Loop
Loop
|