VB6-Code Cleaner v1.0: software to remove numbers when U copy VBCodes from this forum-VBForums
Results 1 to 7 of 7

Thread: VB6-Code Cleaner v1.0: software to remove numbers when U copy VBCodes from this forum

  1. #1

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,572

    VB6-Code Cleaner v1.0: software to remove numbers when U copy VBCodes from this forum

    Hai all..
    You all will be having problem while copying VBCodes from this forum(i.e. VBForums.com).
    I had created this program to remove those numbers present in the VBCode, when you copy it from a thread or a post..

    I think this will be helpful in some way to the users of VBForums.com...

    Kindly post your suggestions and comments...

    I wish to thank my parents and my brother for all their help and encouragement...

    -Regards,
    Akhilesh B Chandran
    Attached Files Attached Files

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India

    Skills: PHP, MySQL, jQuery, VB.Net, VB6, Photoshop...

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    3,584

    Re: VB6-Code Cleaner v1.0: software to remove numbers when U copy VBCodes from this forum

    Heres what I came up with, (with some optimizing help from anhn).
    This is mainly usefull for users of FireFox when copying posted source code in VBForums.

    Code:
    ' Code Cleaner v1.2 - Ed Wilk / Edgemeal May 29th, 2008
    '
    ' Removes prefixed spaces if all lines
    ' have at least one prefixed space character.
    ' Removes those unwanted lines with numbers and # characters.
    
    Public Function CodeCleaner(sText As String) As String
            
        Dim s() As String
        Dim l As Long, EmptySpace As Long
        Dim RemovedItem As Boolean
        
        ' put text into array, seperated by carraige returns.
        s = Split(sText, vbCrLf)
        ' remove empty array items and items that start with a number or a "#" character.
        Do
            RemovedItem = False
            For l = 0 To UBound(s)
                If Len(s(l)) = 0 Or IsNumeric(s(l)) Or (s(l)) = "#" Then
                    RemoveArrayItem s, l
                    RemovedItem = True
                    Exit For
                End If
            Next l
            If RemovedItem = False Then Exit Do
        Loop
        ' remove excess prefix space characters.
        Do
            For l = 0 To UBound(s)
                If Mid$(s(l), 1, 1) <> " " Then Exit Do
            Next l
            For l = 0 To UBound(s)
                s(l) = Mid$(s(l), 2)
            Next l
        Loop ' check for more prefixed spaces.
        
        ' Re-Join array items & return.
        CodeCleaner = Join(s, vbCrLf)
        
    End Function
    
    Private Sub RemoveArrayItem(ByRef Arry As Variant, ByVal Lindex As Long)
        Dim k As Long
        If Lindex < UBound(Arry) Then
            For k = Lindex To UBound(Arry) - 1
                Arry(k) = Arry(k + 1)
            Next k
        End If
        ReDim Preserve Arry(UBound(Arry) - 1)
    End Sub

  3. #3

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,572

    Re: VB6-Code Cleaner v1.0: software to remove numbers when U copy VBCodes from this forum

    Thanks for sharing it....

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India

    Skills: PHP, MySQL, jQuery, VB.Net, VB6, Photoshop...

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: VB6-Code Cleaner v1.0: software to remove numbers when U copy VBCodes from this forum

    Here is a bookmarklet for Firefox that you might find useful/interesting. For easy use make sure you have a bookmark toolbar visible (View > Toolbars), then add a new bookmark to there by right clicking it > New bookmark... and title it as VBcode and make it's url the following:

    Code:
    javascript:var%20s=new%20Array();s=document.getSelection().split("#\r\n");var%20j=s.join('');document.innerHTML+='<textarea%20id="a"%20style="position:fixed;left:0;top:0;width:100%;height:100%"%20onmouseover="this.select()"%20onkeypress="history.go(-1)">'+j+'</textarea>'
    Now when you select code (or anything else on the page) and click that button, you will get a textbox that gets selected as you move your mouse a little, and you can push Ctrl + C to copy and get back to where you were.

    I had to do it like this because by default you can't use JavaScript in Firefox to copy stuff into the clipboard due to security issues it arises when it is enabled.

  5. #5

    Thread Starter
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,572

    Re: VB6-Code Cleaner v1.0: software to remove numbers when U copy VBCodes from this forum

    Thanks Merri
    thankr for sharing it

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India

    Skills: PHP, MySQL, jQuery, VB.Net, VB6, Photoshop...

  6. #6
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    3,584

    Re: VB6-Code Cleaner v1.0: software to remove numbers when U copy VBCodes from this forum

    Quote Originally Posted by Merri
    Here is a bookmarklet for Firefox
    Hmmmm all I get back is one long continuous line of code.

  7. #7
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: VB6-Code Cleaner v1.0: software to remove numbers when U copy VBCodes from this forum

    Don't use it on regular code blocks, use it on the highlighted ones. Regular code blocks you can just select with your mouse and Ctrl + C, no point going through a button.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.