Re: Removing html tags from field

From: Graham R Seach (gseach_at_NOSPAMpacificdb.com.au)
Date: 07/29/04


Date: Thu, 29 Jul 2004 16:02:12 +1000

I just remembered - you want to replace the tags with a space or something.

Public Function KillHTML(sText As String, sReplaceWith As String) As String
    'Kills HTML tags
    Dim iLeft As Integer
    Dim iRight As Integer
    Dim sTmp As String

    iLeft = InStr(1, sText, "<")
    While iLeft > 0
        iRight = InStr(iLeft + 1, sText, ">")
        sTmp = Mid(sText, iLeft, iRight - iLeft + 1)
        sText = Mid(sText, 1, iLeft - 1) & sReplaceWith & Mid(sText, iLeft +
Len(sTmp))
        iLeft = InStr(1, sText, "<")
    Wend

    KillHTML = sText
End Function

You can call this function from SQL, like so:
    SELECT KillHTML([myField], " ") As NewText
    FROM tblMyTable

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html

"JA" <jarmour@kc.rr.com> wrote in message
news:68%Nc.56136$vN3.6971@twister.rdc-kc.rr.com...
> First, thank you all who answered my previous questions. And now I have
> another.
>
> Is there a way to remove html tags from a memo field? Like a way to remove
> the "<" and the ">" and anything in between them. And maybe replace them
> with a space? There would most likely be more than one tag per record.
>
> Thanks again!
>
> JA
>
>



Relevant Pages

  • Re: trouble with onchange event
    ... there are in fact quite a few tags on the page. ... determined that sleeping for a length of time resolves the problem as ... elementToSelect As Long, elementValue As String, ID As String) ... Dim varTags as Variant ...
    (microsoft.public.excel.programming)
  • Re: Please help:need to read XML, edit, and write back to XML file
    ... I copied Astrid's code into a VBA module and ran it, ... give me any of the tags. ... string, as the scripting code gave me. ... reading, writing or appending. ...
    (microsoft.public.word.vba.general)
  • RE: [PHP] Need help with RegEx
    ... The End of string symbol ^ should not be included. ... I want what is inside the tags. ... fifth atom = all of the rest of the source html after the closing ...
    (php.general)
  • Re: Please help:need to read XML, edit, and write back to XML file
    ... And it's perfect - it puts everything in a string with all the tags, ... of the code can be used in a VBA routine. ... the information in the various forms and generates an XML file. ...
    (microsoft.public.word.vba.general)
  • Re: Parsing information out of a command line
    ... > using command line prompts but not striping the data apart once it is ... The only restriction this code has is that your tags ... Dim MyID As String ... Dim MyXValue As String ...
    (microsoft.public.vb.general.discussion)

Loading