Results 1 to 3 of 3

Thread: Html comments removing...

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Thumbs up

    Hi Everyone, After a Long Time..Eh..

    I have a coldfusion file that contains html (!--HTML Comments--> and coldfusion comments<!---CFML Comments--->

    I need to find all the comment blocks and remove it. Is it possible to do this in VB. A program that takes the filename a parameter and removes all the comments inside the file.

    Please do help me immdly as i have to convert this into ocx file and convert into a component and use it in coldfusion custom tags for getting my project work.

    Thanx for any help..

    (BTW How are you Serge....)

    Venkat.
    Thanks and Regards,
    Venkat.

  2. #2
    Guest
    Try this:
    Code:
    Dim hFile As Long
    Dim sFileName As String
    Dim sContents As String
    Dim sLine As String
    Dim I As Integer
    Dim iTemp As Integer
    'Store the filename in sFileName
    
    hFile = FreeFile
    Open sFileName For Input As hFile
        Do While Not EOF(hFile)
            Line Input #hFile, sLine
            sContents = sContents & sLine & vbCrLf
        Loop
    Close hFile
    
    Do
        DoEvents
        I = InStr(1, sContents, "<!--")
        If I = 0 Then Exit Do
        iTemp = InStr(I, sContents, "-->")
        If iTemp = 0 Then Exit Do
        sContents = Left(sContents, I - 1) & Right(sContents, Len(sContents) - (iTemp + 2))
    Loop
    
    hFile = FreeFile
    Open sFileName For Output As hFile
        Print #hFile, sContents
    Close hFile
    Let me know if it works, I wrote the code directly to the post.

  3. #3

    Thread Starter
    Hyperactive Member venkatraman_r's Avatar
    Join Date
    Jul 1999
    Location
    Chennai, INDIA
    Posts
    284

    Thumbs up Thank U

    Thanx man,

    will try it and get back to u if i have any problem..

    regards,
    venkat.
    Thanks and Regards,
    Venkat.

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