Results 1 to 8 of 8

Thread: #region

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    #region

    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
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    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#...

  3. #3
    New Member sokkmees's Avatar
    Join Date
    Sep 2002
    Location
    Estonia
    Posts
    11
    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.

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    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.

  5. #5
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    #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.
    Whadayamean it doesn't work....
    It works fine on my machine!

  6. #6
    Member
    Join Date
    Jun 2004
    Location
    The Netherlands
    Posts
    37
    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?

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    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?
    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.

    TG
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    Lively Member TLord's Avatar
    Join Date
    Jun 2004
    Posts
    95
    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.
    The problem maybe really this type...
    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:
    1. #Region "Here put the caption text"
    2. . . .
    3. #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...
    Last edited by TLord; Jul 10th, 2004 at 12:15 PM.
    Do you think my life is easy?
    Do you think it's good to win?
    do you think it's nice to kill?
    Do you think learning is a must?
    Do you think computers are nothing?
    Do you think this post is stupid?
    Do ypu think we're really humen?

    DO YOU THINK IT'S GOOD TO THINK AT ALL? ? ? ! ! !

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