Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 299
  • Last Modified:

Collapse Part of Code

Is there a way to create an outline or collapse part of code inside a function, like (if/end if) (for/next),(do/loop) etc using Visual Studio ?

thank tou
0
jr_barros_jr
Asked:
jr_barros_jr
  • 5
  • 2
  • 2
  • +1
2 Solutions
 
silemoneCommented:
#region

#endregion


0
 
silemoneCommented:
put code in between and you can collapse it/expand it at will in vs
0
 
käµfm³d 👽Commented:
Regions are the way to go, however, as your Zone is marked Vb.NET, regions are more restricted in VB. You cannot place them inside of a method body (the sytax checker will complain). You can use regions to collapse groups of methods, though.

You also must give your region a name (as a quoted string).
'Error
    Sub Main()
        #region "MyRegion"
        For i As Integer = 0 To 16
            Console.Write("a")
        Next
        #end region
    End Sub

' Proper
#Region "MyRegion"   <-- Must use quotes

    Sub Main()
        For i As Integer = 0 To 16
            Console.Write("a")
        Next
    End Sub

    Sub dosomething()

    End Sub
#End Region

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
jr_barros_jrAuthor Commented:
Folks,

"'#Region' and '#End Region' statements are not valid within method bodies." (See attached picture)

So, #Region is only the solution outside "method". I would like to know inside sub, function, methods etc.

Any idea?


ExEx.png
0
 
silemoneCommented:
change the language you're programming - i.e. use c# instead...unfortunately vb.net does not allow this...
0
 
silemoneCommented:
otherwise you could change IDE's i suppose to one that may parse and compile vb and take into consideration regions inside of a method...
0
 
silemoneCommented:
maybe outlining is the way to go...look at this article...

http://stackoverflow.com/questions/285422/visual-studio-c-statement-collapsing

I'm unsure on this..i'm testing it...but as far as I know C# only does this...
0
 
käµfm³d 👽Commented:
See previous comment.
0
 
jr_barros_jrAuthor Commented:
Is there any workaround for that?
0
 
magicdlfCommented:
You have to wait VS 2010 to have full support to your requirements. See this:
http://social.msdn.microsoft.com/Forums/en-US/vs2010ctpcpp/thread/6f3d4fed-55fd-4280-9a9b-62f0be1e462d
There's a workaround but you need to refactor your code:
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23754826.html
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now