Thanks. Silly question but just for clarification, if I need to separate my
code into several areas like this;
mycompany.dataaccess. ...
mycompany.ui. ...
etc.
and each of these I would like as separate files (so I can import only the
ones I need), where do I make this distinction in my class library?
Just as an example, create a ClassLibrary. Right Click on the project and
select Project Properties. There is an item called Root Namespace. This
is commonly set to the Company name (e. g. MyCompany).
Then add one or more classes to the Library. At the top of the class, add
a namespace statement. For example if the class in question was for
fileio, you could do this:
'In FileIO.vb
Namespace FileIO
Public Class Class1
End Class
Public Class Class2
End Class
End Namespace
Then, in another project, you can add a reference to the class library and
add:
'In SomeOtherProject.vb
Imports MyCompany.FileIO
Private Sub SomeSub()
Dim o As New Class1
Dim p As New Class2
'...etc.
End Sub
Using the Namespace statement, you can add any number of sub levels. For
example, in another class you do this:
'In SomeOtherClass.vb
Namespace FileIO.Special
Public Class SpecialClass1
End Class
End Namespace
And even though that is in a different .dll, it would still be imported
like this:
Imports MyCompany.FileIO.Special
Public Sub AnotherSub()
Dim x As New SpecialClass1
End Sub
Look up the Namespace statement in the help and that should get you
started. I think it is good practice to set you root namespace to the
company name or some unique identifier.
Hope this helps