|
-
May 24th, 2009, 10:11 AM
#11
Thread Starter
Banned
Re: get text between text
 Originally Posted by Merri
Just to point it out, anhn's code will give invalid results if there are more of the first tag than the last tag. It would need to check whether the UBound of the second tag Split is 1. If it is 0, no second tag was found and thus it should not be added into the array.
Edit!
Updating for the title parsing:
Code:
Private Sub Form_Load()
Dim strText As String, strData() As String, strRow() As String
Dim lngA As Long
' open data from file
Open "C:\data.txt" For Input As #1
strText = Input(LOF(1), #1)
Close #1
' if we get more than none...
For lngA = 0 To Between(strText, " title=""", "&c", strData) - 1
strRow = Split(strData(lngA), """ href=""karte.php?d=", 2)
If LenB(strRow(0)) Then Debug.Print strRow(1), strRow(0)
Next lngA
End Sub
Edit #2!
anhn's suggestion functionalized and fixed the issue:
Code:
Public Function Between(Text As String, Before As String, After As String, Output() As String) As Long
Dim lngA As Long, strBetween() As String
Output = Split(Text, Before)
For lngA = 1 To UBound(Output)
strBetween = Split(Output(lngA), After, 2)
If UBound(strBetween) = 1 Then
Output(Between) = strBetween(0)
Between = Between + 1
End If
Next lngA
If Between > 0 Then
ReDim Preserve Output(Between - 1)
Else
Output = Split(vbNullString)
End If
End Function
thanks for your code again 
a new problem is that i cant get the results into text1.text
how can i do this?
thanks
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
|