|
-
Feb 18th, 2000, 09:58 PM
#1
Thread Starter
Member
howdy all.
I have a html document loading in a rich text box, I was just wondering is it possible to find and extract all the links out of the rich text box and place them in a list? and if so can someone help me out with a code?
thanx
------------------
Mooose
-
Feb 18th, 2000, 11:54 PM
#2
Hyperactive Member
This code will search out and retrieve all the text inbetween <tt> tags. you could replace it with the <href> tags. The begining part works with the actual html file to add proper line feeds but if you are getting the file from the text of a richtext box, you can skip it.
Function ReadWeb(strFile As String)
Dim fnum As Long
Dim WholeFile As String
Dim char As String
Dim lines() As String
Dim i As Integer
Dim charPos As Integer
Dim intI As Integer
Dim intFreeFile As Integer
Dim strTTArray() As String
'this will take a web created file and convert it so that I can read it
'the web file is missing chr(13) - carriage return and I need to add it
'it leaves the original file - makes a new .tmp file
fnum = FreeFile
Open strFile For Binary As fnum ' Open file.
WholeFile = Space(LOF(fnum))
Get fnum, , WholeFile
Close fnum
charPos = InStr(WholeFile, Chr(10))
While charPos <> 0
charPos = InStr(WholeFile, Chr(10))
ReDim Preserve lines(i + 1)
If charPos <> 0 Then
If WholeFile <> "" Then
lines(i) = Left(WholeFile, charPos - 1)
'trim the text
WholeFile = Mid(WholeFile, charPos + 1)
i = i + 1
End If
End If
Wend
ok, the part abouve is just doing stuff with the file itself, if you don't want to use this part, just comment it out. But what you would have to do then is modify the code below. The code above dumps each line into an array, of which 'i' is the count. So you would have to get a count of the lines in the richtext box and then set up a loop to pull the lines 1 line at a time. If you can't get it to work, let me know and I'll see what I can do.
ReDim strTTArray(i)
Dim intJ As Integer, strTemp As String, strTemp2 As String, intK As Integer
Dim booFirst As Boolean, booBetween As Boolean
For intI = 0 To i 'this is the array
strTemp = lines(intI) 'get the first line
'MsgBox strTemp
intJ = InStr(strTemp, "tt") 'check for tt
If intJ = 0 Then 'wasn't found in this line
'need to add this line to the strText if have already found the begining tag
If booFirst = True Then
strText = strText & strTemp
End If
Else
'found instance of tt
If booFirst = True Then
'already found begining tag, so this is end tag
strText = strText & Mid(strTemp, 1, intJ - 1)
booFirst = False
'set first to false so that it looks for the <tt> again
booBetween = True
'have found closing tag
Else 'this is beginging tag
booFirst = True
booBetween = False
strText = Mid$(strTemp, intJ + 3) 'goes after the <tt>
intK = InStr(strText, "tt") 'have to check to see if tag ends on this line
If intK <> 0 Then
'this means that the end <tt> is on this line
strText = Mid(strText, 1, intK - 1)
booFirst = False
booBetween = True
'so have found closing tag
End If
End If
End If
If booBetween = True Then
'this means that have grabbed data inbetween the 2 tags, store it and clear variables
strTTArray(intI) = strText
strText = ""
booBetween = False
booFirst = False
MsgBox strTTArray(intI)
End If
Next intI
'now strttarray should contain all the data inbetween the TT tags
End Function
-
Feb 19th, 2000, 09:57 AM
#3
Member
Hi there...
I was also wondering at one point... what do you mean by "loading a HTML file into a rich text box" Mooose? The source code or the web-page such as Internet Explorer does it?
Tnx for answering
-
Feb 19th, 2000, 10:38 AM
#4
Thread Starter
Member
oooops I see what you mean keetsh I stuffed up my explenation a bit, yeah I meant the source code of the page.
------------------
Mooose
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
|