Hi Shapper,
First, you might want to change the name of your namespace and class, as
there is an intrisic class in ASP.Net called "Global" already - hence the
file global.asax. You may be experiencing an ambiguous name reference here,
but you haven't posted your error message, so I can't tell for sure.
The "Imports" statement is a pre-processor statement that allows you to
reference classes and sub-namespaces under a given namespace wihtout having
to type the namespace every time you use it in your code. This can cause an
ambiguous name exception if, for example, you have 2 namespaces with the
same-named class underneath them, and you refer to the class without
refering the namespace in your code. The compiler can't tell which class in
which namespace you're referring to. In your case, as I said, you import
System.Web, and the global.asax file defines a class called "global" that
inherits System.Web.HttpApplication. So, when you refer to
"Global.function1()" the compiler can't tell WHICH Global class you're
referring to.
It is important to understand the difference between namespaces and classes,
and the usage of namespaces. In OOP, you can create a huge number of
classes, such as exist in the CLR. With possibly thousands of classes, it
can become difficult to know when you've given a class the same name as
another one. A namspace is a further identifier for the class, which
references its position in a hierarchy. IOW, a namespace is not a class, but
a container for classes which helps to uniquely identify them.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:Oo**************@TK2MSFTNGP15.phx.gbl...
Hello,
In the main root of my web site together with my aspx and aspx.vb files I
have the file global.vb.
This file has a class with all the functions which are used in many
aspx.vb files and it is like this:
Imports System
Namespace Global
Public Class Global
Public Shared Sub Function01()
...
End Sub
... End Class
End Namespace
In my aspx.vb file I am using the function like this:
Global.function01()
It's not working. I know I am missing some declaration but the options I
tried are not working. I tried to place in my aspx.vb "Imports Global".
Thanks,
Miguel