Results 1 to 2 of 2

Thread: remove text from string

  1. #1

    Thread Starter
    Addicted Member Smie's Avatar
    Join Date
    Jun 1999
    Location
    Columbus, OH
    Posts
    249

    Question

    how would I remove any text in a string that is between "<" and ">"? Im working on removing HTML from a string. Thanks for your help!

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    I worked on this a little bit, this version only works if all the HTML is correct, so it's not very useful if there are mistakes, and I haven't done a lot of testing, but here:

    Code:
    Private Function RemoveHTML(strString As String) As String
    
    Dim intStart As Integer
    Dim intLength As Integer
    Dim intEnd As Integer
    Dim strLookFor As String
        
    If InStr(1, strString, "<") <> 0 Then
        Do Until InStr(1, strString, "<") = 0
        
            intStart = InStr(1, strString, "<")
            If intStart > 0 Then
                intEnd = InStr(intStart, strString, ">")
                    If intEnd > 0 Then
                        intLength = intEnd - intStart
                        strlookup = Mid(strString, intStart, intLength + 1)
                        strString = Replace(strString, strlookup, "")
                    End If
            End If
        
        Loop
        
    End If
        
    RemoveHTML = strString
    
    End Function
    
    'usage
    Private Sub Command1_Click()
    Text1.Text = RemoveHTML(Text1.Text)
    End Sub
    this removes anything between "<" and ">"
    let me know if you come up with anything else.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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