Results 1 to 3 of 3

Thread: Remove Blank Lines and Extra Spaces

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2020
    Location
    Victoria Texas 77904
    Posts
    40

    Remove Blank Lines and Extra Spaces

    This code will remove blank lines and spaces from your code and resave it converted. I would like it to keep a one blank line between procedures but haven't been able to figure it out yet. If anyone can come up with a solution I would appreciate it.
    Attached Files Attached Files

  2. #2

    Thread Starter
    Member
    Join Date
    Aug 2020
    Location
    Victoria Texas 77904
    Posts
    40

    Re: Remove Blank Lines and Extra Spaces

    Seems no one has a solution to my problem. Didn't think it was that hard to do .

  3. #3
    PowerPoster
    Join Date
    Feb 2017
    Posts
    3,274

    Re: Remove Blank Lines and Extra Spaces

    The ParseCode procedure does nothing, you can remove it.

    At the last line of cmdExecute_Click, instead of ParseCode, put this:

    Code:
    Text2.Text = SeparateProcedures(Text2.Text)
    And add this code:

    Code:
    Private Function SeparateProcedures(nText As String) As String
       Dim Lines() As String
       Dim c As Long
       Dim b As Boolean
       
       Lines = Split(nText, vbCrLf)
       For c = 0 To UBound(Lines)
          b = False
          If Left(Lines(c), 12) = "Private Sub " Then
             b = True
          ElseIf Left(Lines(c), 17) = "Private Function " Then
             b = True
          ElseIf Left(Lines(c), 17) = "Private Property " Then
             b = True
          ElseIf Left(Lines(c), 11) = "Public Sub " Then
             b = True
          ElseIf Left(Lines(c), 16) = "Public Function " Then
             b = True
          ElseIf Left(Lines(c), 16) = "Public Property " Then
             b = True
          ElseIf Left(Lines(c), 11) = "Friend Sub " Then
             b = True
          ElseIf Left(Lines(c), 16) = "Friend Function " Then
             b = True
          ElseIf Left(Lines(c), 16) = "Friend Property " Then
             b = True
          ElseIf Left(Lines(c), 4) = "Sub " Then
             b = True
          ElseIf Left(Lines(c), 9) = "Function " Then
             b = True
          ElseIf Left(Lines(c), 9) = "Property " Then
             b = True
          End If
          If b Then
            Lines(c) = vbCrLf & Lines(c)
          End If
       Next
       SeparateProcedures = Join(Lines, vbCrLf)
    End Function

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