Results 1 to 2 of 2

Thread: Help with formatting a string..

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195

    Help with formatting a string..

    I have a html document's source in a textbox.. how can i search for "<table width="640" border="0" cellspacing="0" cellpadding="0" height="10">" and put all data between the starting "<table..." to the second "</table>" in another textbox?

    for example in the textbox with the source theres..

    <body>
    lots of junk here
    <table width="640" border="0" cellspacing="0" cellpadding="0" height="10"><tr></tr></table>
    <table>
    stuff inside the table
    </table>
    more junk here

    and then after running the program, the second textbox will contain
    <table width="640" border="0" cellspacing="0" cellpadding="0" height="10"><tr></tr></table>
    <table>
    stuff inside the table
    </table>


    anyone know how to do this?

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    There are many ways to do this and I'm sure that mine is probably not the best... But that's what you get for running on 2 hours sleep and eating nothing but chocolate coffee beans all day to stay awake. Any way, for this example you'll need a form with two text boxes labeled txtSource and txtFound, then you'll need a command button to execute the code.

    Code:
    Dim i_Search As Integer, i_SearchEnd As Integer, isFirstLoop As Boolean
    i_Search = 1
    isFirstLoop = True
    Do While i_Search <> 0
        i_Search = InStr(IIf(isFirstLoop = True, i_Search, i_Search + 1), txtSource.Text, "<table")
        If i_Search <> 0 Then
            i_SearchEnd = InStr(i_Search, txtSource.Text, "</table>")
            txtFound.Text = txtFound.Text & Mid(txtSource.Text, i_Search, (Len(txtSource.Text) - i_Search) + 8)
        End If
        isFirstLoop = False
    Loop
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

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