|
-
Jan 13th, 2006, 06:39 PM
#1
Thread Starter
Giants World Champs!!!!
[RESOLVED] #Region?
I hope this doesn't sound like a stupid question but what is the #Region namespace do?
Thanks from a frustrated VB6 Programmer.
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Jan 13th, 2006, 06:44 PM
#2
Re: #Region?
Its not a namespace per se. It a way to create a custom grouping of code. Its only for ease of reading.
You can make one to hold related code or properties etc. Whatever you want.
VB Code:
#Region "RobDog's Code" 'My Region
Private Sub Button1_Click(sender blah blah...
Messagebox.show("Blah")
End Sub
End Region
'Example of it collapsed.
"RobDog's Code"
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 13th, 2006, 06:56 PM
#3
Thread Starter
Giants World Champs!!!!
Re: #Region?
Thanks for the post and congrats on your MVP well deserved .
So let me get this straight, it is just used for formatting your code, in order to allow your code to be read easier. Wherever the #Region is located will allow you to collapse the code inbetween the "Tags"?
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Jan 13th, 2006, 08:51 PM
#4
Thread Starter
Giants World Champs!!!!
Re: #Region?
 Originally Posted by RobDog888
Its not a namespace per se. It a way to create a custom grouping of code. Its only for ease of reading.
You can make one to hold related code or properties etc. Whatever you want.
VB Code:
#Region "RobDog's Code" 'My Region
Private Sub Button1_Click(sender blah blah...
Messagebox.show("Blah")
End Sub
End Region
'Example of it collapsed.
"RobDog's Code"
Ok, thanks I figured it out, one note the End Region requires a # before the word End:
VB Code:
#Region "Mark's Code" 'My Region
'Put your code here
#End Region
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Jan 13th, 2006, 08:55 PM
#5
Re: [RESOLVED] #Region?
Any line of code that starts with "#" is not compiled. Code regions are purely an IDE device to make code more readable. They have nothing whatsoever to do with the language (VB) or the platform (.NET). They are purely for Visual Studio's use.
-
Jan 13th, 2006, 09:07 PM
#6
Thread Starter
Giants World Champs!!!!
Re: [RESOLVED] #Region?
 Originally Posted by jmcilhinney
Any line of code that starts with "#" is not compiled. Code regions are purely an IDE device to make code more readable. They have nothing whatsoever to do with the language (VB) or the platform (.NET). They are purely for Visual Studio's use.
Thanks for the post, I was a little confused as to what it was used for but as usual the members of VBF cleared it up for me !
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Jan 13th, 2006, 09:59 PM
#7
Re: [RESOLVED] #Region?
 Originally Posted by jmcilhinney
Any line of code that starts with "#" is not compiled. Code regions are purely an IDE device to make code more readable. They have nothing whatsoever to do with the language (VB) or the platform (.NET). They are purely for Visual Studio's use.
Unless you're using C++ since # usually begins a preprocessor statement
-
Jan 13th, 2006, 10:41 PM
#8
Re: [RESOLVED] #Region?
 Originally Posted by kasracer
Unless you're using C++ since # usually begins a preprocessor statement
You confirm my point. The line beginning with the "#" is not compiled. It is an instruction to the compiler/preprocessor. VB.NET supports conditional compilation these days, a la the C preprocessor, e.g.
VB Code:
Try
IO.File.Delete(path)
Catch ex As Exception
#If DEBUG Then
MessageBox.Show(ex.ToString())
#Else
MessageBox.Show("The file could not be deleted.", "I/O Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
#End If
End Try
-
Jan 13th, 2006, 10:58 PM
#9
Re: [RESOLVED] #Region?
 Originally Posted by jmcilhinney
You confirm my point. The line beginning with the "#" is not compiled. It is an instruction to the compiler/preprocessor. VB.NET supports conditional compilation these days, a la the C preprocessor, e.g.
I know. I just wanted to add that incase someone saw this post and tried to use a REGION in C++
-
Jan 13th, 2006, 11:08 PM
#10
Re: [RESOLVED] #Region?
You can create regions in C++ as well. In VC++ you use "#pragma region" and "#pragma endregion". Like I said, it's a Visual Studio feature, so it will only work in Visual Studio.
-
Jan 13th, 2006, 11:14 PM
#11
Re: [RESOLVED] #Region?
Even with conditional compilation it wont confuse the #If with the #Region since it probably doesnt look at just the # character.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 14th, 2006, 12:57 AM
#12
Re: [RESOLVED] #Region?
[picky]They are not statements or instructions, they are called "Directives" [/picky]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|