none
How to organize multiple classes within a solution? RRS feed

  • Question

  • Hi,

    I would like to add multiple classes in a VB.NET project (solution), and bundle them to a single DLL. For instance, below are a few example class:

    Package email class

    Package encryption class

    Package email class

    Package data access class.

    At the moment, I put each class as separate xxx.VB file, and assign individual NameSpace to each one. Just would like to know how other people handle this situation, and your suggestions are most welcome.

    Thanks in advance!

    Tuesday, February 3, 2015 7:00 PM

Answers

  • I would also put each class definition in a separate .vb file but I would use the same namespace for all classes since they are defined within the same assembly.

    It may make sense to put the classes in different namespaces if they are "logically" separated but then you may want to create another class library and perhaps put two of the four classes or so in there if there is no relation between the classes. Judging by the names of your classes, I would put them in the same namespace in the same project/assembly though.

    Please remember to mark helpful posts as answer and/or helpful.

    • Marked as answer by nzcncf1 Wednesday, February 4, 2015 10:50 PM
    Tuesday, February 3, 2015 9:35 PM
  • Any limit of how many class (.vb) files can be in a project? Thanks.

    No, there is no theoretical limit on how many classes you can add to a project.

    But please don't ask several questions in the same thread and please remember to close your threads by marking all helpful posts as answer.

    • Marked as answer by nzcncf1 Wednesday, February 4, 2015 10:50 PM
    Wednesday, February 4, 2015 9:17 PM
  • you can add all of you classes in one .vb

    usually I wrote my codes in C#, but I had to switch to VB for working with Excel and I added all of my classes in one  file  .vb and made the dll.

    it is working without any problem.

    • Marked as answer by nzcncf1 Wednesday, February 4, 2015 10:50 PM
    Wednesday, February 4, 2015 10:13 PM

All replies

  • I would also put each class definition in a separate .vb file but I would use the same namespace for all classes since they are defined within the same assembly.

    It may make sense to put the classes in different namespaces if they are "logically" separated but then you may want to create another class library and perhaps put two of the four classes or so in there if there is no relation between the classes. Judging by the names of your classes, I would put them in the same namespace in the same project/assembly though.

    Please remember to mark helpful posts as answer and/or helpful.

    • Marked as answer by nzcncf1 Wednesday, February 4, 2015 10:50 PM
    Tuesday, February 3, 2015 9:35 PM
  • Any limit of how many class (.vb) files can be in a project? Thanks.
    Wednesday, February 4, 2015 7:05 PM
  • Any limit of how many class (.vb) files can be in a project? Thanks.

    No, there is no theoretical limit on how many classes you can add to a project.

    But please don't ask several questions in the same thread and please remember to close your threads by marking all helpful posts as answer.

    • Marked as answer by nzcncf1 Wednesday, February 4, 2015 10:50 PM
    Wednesday, February 4, 2015 9:17 PM
  • you can add all of you classes in one .vb

    usually I wrote my codes in C#, but I had to switch to VB for working with Excel and I added all of my classes in one  file  .vb and made the dll.

    it is working without any problem.

    • Marked as answer by nzcncf1 Wednesday, February 4, 2015 10:50 PM
    Wednesday, February 4, 2015 10:13 PM