|
|
A Visual Basic 6 Module was a popular tool to create a library (if you will) of global routines and variables that you would want to access from multiple places in your code. It allow programmers to be able to maintain and access routines in one place. Basically it can be viewed as a global class available to all other forms and classes. No instantiation needed, it is already instantiated and global. Very convenient to use.
VB6 was primarily a single-user desktop windows applications development tool. Yes, with the proper level of skill and patience you could use it more advanced purposes. In a single user environment, a shared global module is not a problem. Use of a module in a single user VB.Net application is still not a problem for the same reason. But in asp there is a problem. If you consider what might happen if you use a module in an ASP.Net application being used by multiple users you might note that a variable declared at the module level is now a global variable that can is accessed by every instance that touches it without clearing the prior setting. For instance 'UserName' if not reset will be the prior user name set when the function was called. This was not really a problem in VB6 window applications but could be in VB.net. And potentially a tremendous security issues as incoming users take on whatever security permissions were enabled by the last client that set the 'UserName' variable.
So the use of a class while a little more code is required is a better way for ASP code to have a standard “library” of routines that you want to call from many locations in your code. A class will contain your methods (routines) properties (variables) and events. VB6 Had the class file also and was and is used extensively in desktop applications. But as pointed out above in ASP code there is a definite need to secure access to variables for each instance. Classes allow instantiating an individual instance for each use and that keeps each instance unaware of the others.
See this article that describes a class in MS terminology and this article that details different project file types.
Here are a couple of links to easy tutorials for class creations 1 & 2
Share/Save This Article:
Only registered users may post comments.