I'm trying to migrate some C# code over to VB and have hit a snag...
the C# code has this in it...
#region
#endregion
but VB tells me that i can't have this in method bodies...
what can I do here? do I need these?
Thanks,
squirrelly1
Printable View
I'm trying to migrate some C# code over to VB and have hit a snag...
the C# code has this in it...
#region
#endregion
but VB tells me that i can't have this in method bodies...
what can I do here? do I need these?
Thanks,
squirrelly1
if i'm not wrong it is just used for regioning blocks. but prohibited in vb for some reason [which i don't know]. you can do regioning in C# even in control flow blocks. i guess, just delete it.
the thing is that you can't expand-collapse the [should-be region] code in your C#...
Believe that VB says to you :)
Organising your code into regions is not obligatory for compiler, but just good practice to make your coding easily readable.
Why would you have a region block within a method?
If it's so long that it requires a region then your mehod needs to be rewritten.
#Region and #End Region are allowed in VB, I use them all the time for large projects where a class module might contain several thousand lines of code. I think your problem lies in the "#endregion" key word, just put a space between #end and region and that should fix your problem.
I was using outlining (select x lines, right click, outlining, hide selection) works great aswell, but when I start the next day all my outlining is gone and 'standard' outlining is back again....
Is there a way to fix this or is outlining supposed to be short lived and you've got to use #region & #end region for regions that survive a save & reload?
Yeah, I think that type of code hiding only works for the current running of the IDE. I don't think it actualy adds #region tags to it, so they are not saved.Quote:
Originally posted by cphoenixc
I was using outlining (select x lines, right click, outlining, hide selection) works great aswell, but when I start the next day all my outlining is gone and 'standard' outlining is back again....
Is there a way to fix this or is outlining supposed to be short lived and you've got to use #region & #end region for regions that survive a save & reload?
TG
The problem maybe really this type...Quote:
Yeah, I think that type of code hiding only works for the current running of the IDE. I don't think it actualy adds #region tags to it, so they are not saved.
but did you try putting a caption for the #Region...#End Region block?
This is done by inserting constant string value after the #Region keyword, like this:
VB Code:
#Region "Here put the caption text" . . . #End Region
About dividing your method into blocks, #Region statement can't appear in method level, only directly in the class\Module or outside the Class/Module if you want to group the whole Class/Module or several Classes/Modules.
I hope this reply helps... :D