Click to See Complete Forum and Search --> : Finding Data


ecannizzo
May 14th, 2001, 02:39 PM
I have a whole bunch of text in a document and I want to find each time it has a specific word in it and I want to display that word each time in a listbox. Where do I start?

Thanks!
Erica

dfwade
May 14th, 2001, 02:59 PM
look at the LIKE operator in the help file it should do the trick and you can use wildcard characters with it.

Hope this helps

coolbiz
May 14th, 2001, 03:25 PM
Not sure what exactly you want to do. If you have a bunch of texts and you want to display the occurrences of specific word, that means you'll be populating the listbox with the same word again and again. Anyway, you can try to look at the following functions:

1. Open to open the text file
2. EOF() to determine end-of-file while reading
3. Line Input to read line by line
4. InStr() to search for specific word in a bunch of texts
5. .AddItem method of ListBox to add new text into the list.

Hope this helps,
-Cool Bizs

ecannizzo
May 14th, 2001, 03:29 PM
Thanks for those tips. What I'm trying to do is find how many images are in a document, so I'm using the innerhtml method to get the source code, but now I need to get a list of all the images in it. So I thought if I found every time it used a <img> I could then use the right() to get the name. Do you have any suggestions?

Thanks!
Erica

coolbiz
May 14th, 2001, 04:03 PM
Ooo okay. Consider the following code:


Sub SearchImageTags(szHTML as string)
dim szBuffer as string
dim nCurInd as long
dim nStartInd as long

' uppercase to easy search
szHTML = UCase(szHTML)

' clear current list
List1.Clear

' get the first <IMG
nStartInd = 1
nCurInd = InStr(nStartInd, szHTML, "<IMG")

' loop until nCurInd = 0
while (nCurInd <> 0)
nStartInd = nCurInd ' save the index of the <
nCurInd = InStr(nStartInd+1, szHTML, ">") ' look for the ending >
if (nCurInd <> 0) then
' found it - retrieve the tag (clean it as you see fit)
szBuffer = mid$(szHTML, nStartInd, (nCurInd - nStartInd))
List1.AddItem szBuffer

' advance the start index
nStartInd = nCurInd + 1
nCurInd = InStr(nStartInd, szHTML, "<IMG")
end if
wend
End Sub




I have it really tested the code so work with it to make it work.
-Cool Bizs

ecannizzo
May 14th, 2001, 04:10 PM
Thank you for your help!