Click to See Complete Forum and Search --> : String manipulation question
andywallace
Dec 14th, 1999, 03:17 AM
Hi all
can any one help me with this problem. I am searching a string which contains the data from a web page, i search the string using instr for a particular word in this case it is a url. i can then copy this url to another string but what i want to be able to do is retrive the html tag information stored between <b>info in need </b> tags ,the info between these tags varies in size but is allwat the tag befor the url i can alreadt retrive.
any help please.
Andy@webfx3.freeserve.co.uk
Aaron Young
Dec 14th, 1999, 03:22 AM
Use Instr to Find the Tag <b> then from the Value returned do another Instr for the Tag </b>, then you can grab the string using Mid with the 2 Values, eg.
Dim iStart As Integer
Dim iEnd As Integer
Dim sTag As String
iStart = InStr(sHTML, "<b>")
iEnd = InStr(iStart, sHTML, "</b>")
sTag = Mid$(sHTML, iStart + 3, (iEnd - iStart) - 3)
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
andywallace
Dec 14th, 1999, 03:32 AM
Hi again
not sure i explained my problem very vell. There are several urls on the page i need to search from one particular url and retrive the data between the <b> tage in front of the url. This means i am unable to use instr to search for the <b> tags as there are many of them.
andy@webfx3.freeserve.co.uk
Aaron Young
Dec 14th, 1999, 03:42 AM
If you know the URL then use Instr to search for the URL, then backstep through the String checking for <b> and you'll have your Information, eg.
Private Sub Command1_Click()
Dim iStart As Integer
Dim iEnd As Integer
Dim sTag As String
sHTML = "<HTML><BODY><b>Any old thing</b>some other stuff<b>The Info</b><a href=www.vb-world.net>Link</a>"
iStart = InStr(sHTML, "</b><a href=www.vb-world.net")
iEnd = iStart
While Mid$(sHTML, iStart, 3) <> "<b>"
iStart = iStart - 1
Wend
sTag = Mid$(sHTML, iStart + 3, (iEnd - iStart) - 3)
Caption = sTag
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
andywallace
Dec 14th, 1999, 03:47 AM
Thanks very much that should do it. it was the stepping back bit i was unsure of thenks again
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.