|
-
Aug 4th, 2002, 08:41 PM
#1
Thread Starter
Fanatic Member
Please help with string manipulation (parsing)..
Code:
<td valign=top width=2%><b>· </b></td><td valign=top width=100%><font face=arial size=-1><b><a onclick='return popup("pp121")' href="/?room=Asian%20Markets::1600382635">Asian Markets</a></b><br>discuss the latest market activity.</font></td><script>sc(15,5,0)</script></tr><tr><td>
</td><td valign=top width=2%><b>· </b></td><td valign=top width=100%><font face=arial size=-1><b><a onclick='return popup("pp200")' href="/?room=Biotechnology::1600326508">Biotechnology</a></b><br>Discuss the latest research and advances in this field.</font></td><script>sc(1,1,0)</script></tr><tr><td>
</td><td valign=top width=2%><b>· </b></td><td valign=top width=100%><font face=arial size=-1><b><a onclick='return popup("pp212")' href="/?room=Bond%20Market::1603088415">Bond Market</a></b><br>Come here to chat live about the bond market!</font></td><script>sc(2,1,0)</script></tr><tr><td>
</td>
There are many of these im a html source.. and theres dozens of these sequences in the source.. listing a link with a <script> tag
beside it. how can i create a function to check the value of the 1st number in each <script>sc(x,y,z)</script> (x in this case) in
the order it was seen in the html source?
for example, lets say i wanted to check the value of the 3rd item in the source (in this case, the last)..
Check(3) would return the value of 2, as "<script>sc(2,1,0)</script>" shows 2 as the first number in the 3rd time in the source.
anyone know?
Last edited by n00bie; Aug 4th, 2002 at 08:59 PM.
-
Aug 4th, 2002, 11:49 PM
#2
Hyperactive Member
VB Code:
Public Function Get_Info(Mystr As String, intNumber) As String
Dim I As Integer
Dim Tmp() As String
Dim MyTmp As String
Tmp = Split(mystr, "<")
Do Until I = UBound(Tmp) + 1
If Left(Tmp(I), 10) = "script>sc(" Then
MyTmp = Tmp(I)
Exit Do
End If
I = I + 1
Loop
If Not Len(MyTmp) = 0 Then
MyTmp = Right(MyTmp, 7)
MyTmp = Left(MyTmp, Len(MyTmp) - 1)
Get_Info = Split(MyTmp, ",")(intNumber)
End If
End Function
That Should do It
'Msgbox Get_Info(String, Number)
Visual Baisc 6 (SP5)
Windows Xp
-
Aug 5th, 2002, 07:38 AM
#3
Junior Member
I'm stealing the Split idea from ZeroCool but
I think this will give you the results you were looking for.
You might have to get more specific with
your Split criteria to make sure it will find the correct data everytime.
VB Code:
Public Function Get_Info(Mystr As String, intNumber) As String
Dim I As Integer
Dim Tmp() As String
Tmp = Split(Mystr, "sc(")
Get_Info = Val(Tmp(intNumber))
End Function
Now
MsgBox Get_Info("SomeString",3)
should return what your looking for.
-
Aug 5th, 2002, 09:40 AM
#4
Hyperactive Member
I, too, would use the 'Split' function (as ZeroCool & Sideout suggest), but I'd be more specific on your criteria.
VB Code:
Public Function Get_Info(Mystr As String, intNumber) As String
Dim I As Integer
Dim Tmp() As String
Tmp = Split(Mystr, "[b]<script>[/b]sc(")
Get_Info = Val(Tmp(intNumber))
End Function
Nate
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
|