Results 1 to 5 of 5

Thread: String manipulation question

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Location
    uk
    Posts
    7

    Post

    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



  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    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.
    Code:
    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

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Location
    uk
    Posts
    7

    Post

    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

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    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.
    Code:
    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

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 1999
    Location
    uk
    Posts
    7

    Post

    Thanks very much that should do it. it was the stepping back bit i was unsure of thenks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width