Put common routines in a Class (as Shared) or in a module?
Lars E.Nes
z-one
Effectively there is no difference in what you want to achieve (global methods for the application): you can use a module with subroutines or a class with shaed subroutines. As you've found out, you don't need the module/class name with the module. However, sometimes, qualifying the subroutine makes sense, for example:
I have a routine which validates some strings, I could put the routine in a module and call it thus:
ValidateName(ThisName)
Or, I could put it as a shared subroutine in a class (along with all the other Validate functions...):
Validate.Name(ThisName)
Validate.Thing(ThisThing)
Validate.SomethingElse(TheOtherThing)
...
The advantage of the latter is that I don't have to remember the subroutine names when I end up with 20 different validation functions: intellisense wil pick up he functions when I type Validate. So, usually a class may be better in some respects. You can also make it non-instantiatable (sp ) by adding a private sub new.
To eliminate the requirement to qualify the siubroutine in the class, you use the Imports statement: you wqill need to import your class as follows:
Imports ApplicationNamespace.ClassName
Dmytro Kryvko
You can use an imports statement to keep from using the verbose class name:
Imports MyClass
MySharedSub ()
A Module statement defines a reference type available throughout its namespace. A module (sometimes called a standard module) is similar to a class but with some important distinctions. Every module has exactly one instance and does not need to be created or assigned to a variable. Modules do not support inheritance or implement interfaces. Notice that a module is not a type in the sense that a class or structure is — you cannot declare a programming element to have the data type of a module.
You can use Module only at namespace level. This means the declaration context for a module must be a source file or namespace, and cannot be a class, structure, module, interface, procedure, or block. You cannot nest a module within another module, or within any type. For more information, see Declaration Contexts and Default Access Levels.
A module has the same lifetime as your program. Because its members are all Shared, they also have lifetimes equal to that of the program.
Modules default to Friend (Visual Basic) access. You can adjust their access levels with the access modifiers. For more information, see Access Levels in Visual Basic.
All members of a module are implicitly Shared.

Put common routines in a Class (as Shared) or in a module?
Xfolder