|
-
May 14th, 2001, 02:39 PM
#1
Finding Data
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
-
May 14th, 2001, 02:59 PM
#2
Re: Finding Data
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
-
May 14th, 2001, 03:25 PM
#3
Re: Finding Data
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
Good Luck,
-Cool Bizs
-
May 14th, 2001, 03:29 PM
#4
Re: Finding Data
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
-
May 14th, 2001, 04:03 PM
#5
Re: Finding Data
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
Good Luck,
-Cool Bizs
-
May 14th, 2001, 04:10 PM
#6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|