473,466 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Namespaces in VB.NET

I'm working on a VB library application. I want Visual Studio to
automatically
put in the namespace on the class when I add it under a directory. Like C#
does.

So if I have a directory in my project called /tools, and my default
namespace of the project
is myproject, the editor should put in the namespace of "myproject.tools".
That's how Csharp works.

Does anyone know if this is an option in Visual Studio or something?

Nov 20 '05 #1
9 1388
maxmann,
Does anyone know if this is an option in Visual Studio or something? Unfortunately there is no option to automatically do this.

I normally include the Namespace statement in each source file. Which of
course has issues if you move the file. Note I still set the root namespace
under Project Properties for classes in the project root.

NameSpace Design

Public Class WidgetEditor
End Class

End NameSpace

Hope this helps
Jay

"news.microsoft.com" <ma*****@xceligent.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl... I'm working on a VB library application. I want Visual Studio to
automatically
put in the namespace on the class when I add it under a directory. Like C# does.

So if I have a directory in my project called /tools, and my default
namespace of the project
is myproject, the editor should put in the namespace of "myproject.tools".
That's how Csharp works.

Does anyone know if this is an option in Visual Studio or something?

Nov 20 '05 #2
right. we have the root namespace set, I was just wanting to get around
having to manually add the namespace in for every class file we create.
Doesn't make sense that VB can't do this when C# does it by default.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
maxmann,
Does anyone know if this is an option in Visual Studio or something? Unfortunately there is no option to automatically do this.

I normally include the Namespace statement in each source file. Which of
course has issues if you move the file. Note I still set the root

namespace under Project Properties for classes in the project root.

NameSpace Design

Public Class WidgetEditor
End Class

End NameSpace

Hope this helps
Jay

"news.microsoft.com" <ma*****@xceligent.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl...
I'm working on a VB library application. I want Visual Studio to
automatically
put in the namespace on the class when I add it under a directory. Like

C#
does.

So if I have a directory in my project called /tools, and my default
namespace of the project
is myproject, the editor should put in the namespace of "myproject.tools". That's how Csharp works.

Does anyone know if this is an option in Visual Studio or something?


Nov 20 '05 #3
* "axmann" <ma*****@xceligent.com> scripsit:
right. we have the root namespace set, I was just wanting to get around
having to manually add the namespace in for every class file we create.
Doesn't make sense that VB can't do this when C# does it by default.


You can write an add-in that inserts the code...

;-)))

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Axmann,
I don't think its a matter that VB can't, its a matter that VB does not!

I have to wonder how many VB.NET projects actually include folders. So
adding the feature to VB.NET for the two of us makes sense how? :-)

Also I tend to start all my classes in the root of the project, then when I
have enough classes I tend to move them to folders later, so having the
namespace added when I create the class is not going to help me... Rather
then move them into a folder, I may actually move them into their own class
library assembly. Granted others work differently then you or I.

Also as Herfried stated, you could write a macro or add-in to take care of
it.

I'm not sure if it will be changed in VB.NET 2004 or not.

You could always submit a Wish to Microsoft to have the behavior changed,
not sure if it will make VB.NET 2004 as I understand the beta for VB.NET
2004 will be at PDC.

http://register.microsoft.com/mswish...=EN-US&gssnb=1

Hope this helps
Jay

"axmann" <ma*****@xceligent.com> wrote in message
news:O8**************@TK2MSFTNGP11.phx.gbl...
right. we have the root namespace set, I was just wanting to get around
having to manually add the namespace in for every class file we create.
Doesn't make sense that VB can't do this when C# does it by default.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
maxmann,
Does anyone know if this is an option in Visual Studio or something?

Unfortunately there is no option to automatically do this.

I normally include the Namespace statement in each source file. Which of
course has issues if you move the file. Note I still set the root

namespace
under Project Properties for classes in the project root.

NameSpace Design

Public Class WidgetEditor
End Class

End NameSpace

Hope this helps
Jay

"news.microsoft.com" <ma*****@xceligent.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl...
I'm working on a VB library application. I want Visual Studio to
automatically
put in the namespace on the class when I add it under a directory.
Like
C#
does.

So if I have a directory in my project called /tools, and my default
namespace of the project
is myproject, the editor should put in the namespace of

"myproject.tools". That's how Csharp works.

Does anyone know if this is an option in Visual Studio or something?



Nov 20 '05 #5
Well, for organization sake I would think A LOT of projects, VB or not,
should have code grouped in folders.
I guess if you broke every little piece of functionality into their own dll
you might not, but I would rather not
have to work with 30 different projects myself when the functionality is
closely related, but still groupable.

Also, it's just good coding practice to namespace your classes out
corresponding directly to your folder
structure. I've heard that from the experts. My company recently brought
in Rockford Lhotka (the author)
for .NET training and that's what he recommended.

Anyway, I added it to the wishlist. Thanks for the link. I may try an
add-in, but I have tons of more important
things to do at the moment. :)

thanks, Mark

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Axmann,
I don't think its a matter that VB can't, its a matter that VB does not!

I have to wonder how many VB.NET projects actually include folders. So
adding the feature to VB.NET for the two of us makes sense how? :-)

Also I tend to start all my classes in the root of the project, then when I have enough classes I tend to move them to folders later, so having the
namespace added when I create the class is not going to help me... Rather
then move them into a folder, I may actually move them into their own class library assembly. Granted others work differently then you or I.

Also as Herfried stated, you could write a macro or add-in to take care of
it.

I'm not sure if it will be changed in VB.NET 2004 or not.

You could always submit a Wish to Microsoft to have the behavior changed,
not sure if it will make VB.NET 2004 as I understand the beta for VB.NET
2004 will be at PDC.

http://register.microsoft.com/mswish...=EN-US&gssnb=1
Hope this helps
Jay

"axmann" <ma*****@xceligent.com> wrote in message
news:O8**************@TK2MSFTNGP11.phx.gbl...
right. we have the root namespace set, I was just wanting to get around
having to manually add the namespace in for every class file we create.
Doesn't make sense that VB can't do this when C# does it by default.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in

message
news:%2****************@TK2MSFTNGP10.phx.gbl...
maxmann,
> Does anyone know if this is an option in Visual Studio or something?
Unfortunately there is no option to automatically do this.

I normally include the Namespace statement in each source file. Which of course has issues if you move the file. Note I still set the root

namespace
under Project Properties for classes in the project root.

NameSpace Design

Public Class WidgetEditor
End Class

End NameSpace

Hope this helps
Jay

"news.microsoft.com" <ma*****@xceligent.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl...
> I'm working on a VB library application. I want Visual Studio to
> automatically
> put in the namespace on the class when I add it under a directory. Like C#
> does.
>
> So if I have a directory in my project called /tools, and my default
> namespace of the project
> is myproject, the editor should put in the namespace of

"myproject.tools".
> That's how Csharp works.
>
> Does anyone know if this is an option in Visual Studio or something?
>
>
>



Nov 20 '05 #6
axmann,
Well, for organization sake I would think A LOT of projects, VB or not,
should have code grouped in folders. I believe you miss read me! You and I believe this way, I question if other,
less informed VB.NET programmers know this, especially when coming from VB6
which did not support it!

And yes my estimate of 2 may have been low ;-)
I guess if you broke every little piece of functionality into their own dll you might not, but I would rather not I never said 'little piece', An example of what I meant: Is one project with
500 classes in it better or worse than 10 projects with 50 classes each? I
find 10 projects with 50 classes each to be 'more manageable'. Would I have
5 projects with 100 classes each, I'm not sure. I think it would depend on
how well those classes grouped or didn't. However it is doubtful that I
would have 50 projects with 10 classes each, then again it there were 50
obvious groupings...
Also, it's just good coding practice to namespace your classes out
corresponding directly to your folder structure I never said it wasn't, I almost always do. However like any rule, there are
exceptions that make sense. :-)

If anything I normally do it the other way: I will put classes into a
namespace in the root folder, before I would put files in a folder without a
namespace (if that made sense).

Hope this helps
Jay
"axmann" <ma*****@xceligent.com> wrote in message
news:e%****************@tk2msftngp13.phx.gbl... Well, for organization sake I would think A LOT of projects, VB or not,
should have code grouped in folders.
I guess if you broke every little piece of functionality into their own dll you might not, but I would rather not
have to work with 30 different projects myself when the functionality is
closely related, but still groupable.

Also, it's just good coding practice to namespace your classes out
corresponding directly to your folder
structure. I've heard that from the experts. My company recently brought
in Rockford Lhotka (the author)
for .NET training and that's what he recommended.

Anyway, I added it to the wishlist. Thanks for the link. I may try an
add-in, but I have tons of more important
things to do at the moment. :)

thanks, Mark

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
Axmann,
I don't think its a matter that VB can't, its a matter that VB does not!

I have to wonder how many VB.NET projects actually include folders. So
adding the feature to VB.NET for the two of us makes sense how? :-)

Also I tend to start all my classes in the root of the project, then when
I
have enough classes I tend to move them to folders later, so having the
namespace added when I create the class is not going to help me... Rather then move them into a folder, I may actually move them into their own class
library assembly. Granted others work differently then you or I.

Also as Herfried stated, you could write a macro or add-in to take care of it.

I'm not sure if it will be changed in VB.NET 2004 or not.

You could always submit a Wish to Microsoft to have the behavior changed, not sure if it will make VB.NET 2004 as I understand the beta for VB.NET
2004 will be at PDC.

http://register.microsoft.com/mswish...=EN-US&gssnb=1

Hope this helps
Jay

"axmann" <ma*****@xceligent.com> wrote in message
news:O8**************@TK2MSFTNGP11.phx.gbl...
right. we have the root namespace set, I was just wanting to get around having to manually add the namespace in for every class file we create. Doesn't make sense that VB can't do this when C# does it by default.
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in

message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> maxmann,
> > Does anyone know if this is an option in Visual Studio or something? > Unfortunately there is no option to automatically do this.
>
> I normally include the Namespace statement in each source file. Which of > course has issues if you move the file. Note I still set the root
namespace
> under Project Properties for classes in the project root.
>
> NameSpace Design
>
> Public Class WidgetEditor
> End Class
>
> End NameSpace
>
> Hope this helps
> Jay
>
> "news.microsoft.com" <ma*****@xceligent.com> wrote in message
> news:eG**************@TK2MSFTNGP11.phx.gbl...
> > I'm working on a VB library application. I want Visual Studio to
> > automatically
> > put in the namespace on the class when I add it under a directory.

Like
> C#
> > does.
> >
> > So if I have a directory in my project called /tools, and my

default > > namespace of the project
> > is myproject, the editor should put in the namespace of
"myproject.tools".
> > That's how Csharp works.
> >
> > Does anyone know if this is an option in Visual Studio or something? > >
> >
> >
>
>



Nov 20 '05 #7
Hi Jay, Axman,

2? That's 3, thank you very much!! [much fake indignation, lol]

Actually, though I use folders a lot (and then I might migrate out to
projects), I prefer explicit namespaces. I also have temporary folders where
things are put just so that I don't have to play scroll and click so much. I
wouldn't want any automatic namespaces for those.

I haven't had the pain of too much renaming upheaval but if it comes to
it, ...Hey - opportunity for a utiity. Doesn't even have to be an add-in -
just a console app that reads a bunch of solution files, project files and
directory structures.

Regards,
Fergus
Nov 20 '05 #8
well, I submitted it to the good old MS wish list. We'll see what happens.

I think it would be best if it were an option , that way if you wanted
Visual Studio to do it , it would, and vice versa.

I agree that not every programmer out there would want the feature, but the
option would be helpful.

"Fergus Cooney" <fi******@tesco.net> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Jay, Axman,

2? That's 3, thank you very much!! [much fake indignation, lol]

Actually, though I use folders a lot (and then I might migrate out to
projects), I prefer explicit namespaces. I also have temporary folders where things are put just so that I don't have to play scroll and click so much. I wouldn't want any automatic namespaces for those.

I haven't had the pain of too much renaming upheaval but if it comes to it, ...Hey - opportunity for a utiity. Doesn't even have to be an add-in -
just a console app that reads a bunch of solution files, project files and
directory structures.

Regards,
Fergus

Nov 20 '05 #9
Hi Axmanm,

I'm all in favour of options, so I hope you get your wish.

If ever I do that utility, I will send it to you at xceligent.com ;-)

Regards,
Fergus
Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of...
24
by: Marcin Vorbrodt | last post by:
Here is an example of my code: //Header file #include <vector> using std::vector; namespace Revelation { // class definitions, etc... // class members are of type std::vector }
2
by: Mike Morse | last post by:
What see sample that show xs:element where the xs namespace = http://www.w3.org/2001/XMLSchema However, I see another example with xsi: where xsi = http://www.w3.org/2001/XMLSchema-instance ...
3
by: Jim Heavey | last post by:
Trying to get the hang of Namespaces. I have primarly developed in VB and am transitioning to C# and the .Net Environment. I have worked a bit with Java as well in school about a year or so ago....
17
by: clintonG | last post by:
Using 2.0 with Master Pages and a GlobalBaseClass for the content pages. I understand the easy part -- the hierarchical structure of a namespace naming convention -- but the 2.0 IDE does not...
11
by: Random | last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I understand the purpose is so the developer can put classes within namespaces to essentially organize your code. And I...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.