Code folding - #Region

Discussion in 'Code Samples & Tips' started by Erel, Aug 14, 2007.

  1. Erel

    Erel Administrator Staff Member Licensed User

    One new feature of version 5.50 is code outlining (code folding).
    You can use it to organize your code into blocks.
    Each sub can be folded.
    Using #Region ... #End Region you can manually declare blocks of code that will be foldable and also will be folded by default when you load the file.
    That way you can easily navigate large code.
    Note that you can add a description next to #Region.
    Example:
    Code:
    #Region Form1 Block
    Sub Form1_Show
    ...
    End Sub
    Sub SomeSub
    ...
    End Sub
    ...
    #End Region
     
  2. agraham

    agraham Expert Licensed User

    Very nice! Very useful.
     
  3. alfcen

    alfcen Well-Known Member Licensed User

    Hi Erel
    Formidable!!!
    This reminds me, (perhaps I just missed it), is it possible to fold and unfold all subs in a single action?
    Cheers
    Robert
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You can't fold / unfold all subs in a single action.
    I think it will be available in the next update.
     
  5. alfcen

    alfcen Well-Known Member Licensed User

    Absolutely no problem Erel,
    By the speed of your updates I'm sure this will be intregrated sooner than I estimate :)
     
  6. Rioven

    Rioven Active Member Licensed User

    The folding feature is very useful. I could organise the coding very effectively.
    The folded regions are stored once the file saved, but subs are not.
    Is the folded subs will be stored too on your next update?
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    I think it is better to leave all the subs open when loading a file.
    Next update will allow you to fold / unfold all subs.
    You could of course use #region to wrap large subs that should be folded.
     
Loading...