Hey Scott,
I completely agree after the suggestions from both Tom and you. I can now do that
with the shared methods/properties. I just want to know how vb's module's object is
declared globally without seeing the declaration in the source code. I'm trying to
get some insight on how the innards work.
This is a very interesting question to me. I know, a sure sign of a nerd<grin>.
Thanks Again - Jack
| Hi Jack,
|
| I think you just may need to shift away from the "module" track and head
| more towards the object track. The question is not really, how to make a
| module globally available, it's how to make the object globally available.
| Sure, there are still modules of code, but within that code you can create
| Public classes and/or subs & functions so that they can be accessed from
| other entities in your app.
|
|
| | > Thanks guys for the help. I think I can now make vb.net do what I need!
| I want to
| > make sure I understand what your saying. Below is the 'Reflector'
| decompiled output
| > for a simple vb.net module
| >
| > Private NotInheritable Class Globals Inherits Object Private Shared Sub
| New()
| > Public Shared gString As String
| > End Class
| >
| > 1) If I make all properties/methods Shared, I can achieve the same
| results as a
| > vb.net module. So that's how!
| > 2) vb.net modules cannot inherit from another class because MS
| hard-wired the
| > module to inherit from object only.
| > 3) vb.net module classes (all properties/methods) are somehow declared
| globally as
| > I don't need to create an instance
| > of the Globals module in my code to access the gString property.
| >
| > Do you know how vb.net modules are made global to the application or
| assembly? Also,
| > why didn't they allow modules to be inherited from a class?
| >
| > Thanks for the solution - JackRazz
| >
| >
| > | > | > But (technically) you can't create a shared class. Just a class with
| all
| > | > shared members.
| > |
| > | Technically True, but you can't do that in C# either. It's basically
| > | the same situation. You basically create a sealed class and a private
| > | default constructor and make all your properties and methods static.
| > | That's exactly what a vb.net module ends up as
| > |
| > | Either way, the results are about the same.
| > | --
| > | Tom Shelton [MVP]
| > | OS Name: Microsoft Windows XP Professional
| > | OS Version: 5.1.2600 Service Pack 1 Build 2600
| > | System Up Time: 1 Days, 20 Hours, 39 Minutes, 42 Seconds
| >
| >
|
|