473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

My Class

When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be accessed
in the same fashion.. e.g.

myclass.myfunction("parameter")
Nov 21 '05 #1
23 1432
Take a look at the "static" and "shared" keywords. One of these two should
do this for you. What you're looking for is a non-instanced class
interface.

Mike Ober.

"patang" <pa****@discussions.microsoft.com> wrote in message
news:49**********************************@microsof t.com...
When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be accessed in the same fashion.. e.g.

myclass.myfunction("parameter")


Nov 21 '05 #2
Take a look at the "static" and "shared" keywords. One of these two should
do this for you. What you're looking for is a non-instanced class
interface.

Mike Ober.

"patang" <pa****@discussions.microsoft.com> wrote in message
news:49**********************************@microsof t.com...
When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be accessed in the same fashion.. e.g.

myclass.myfunction("parameter")


Nov 21 '05 #3
I think you are talking about SHARED members. Triy using the SHARED keyword
when declaring your member. You should be able to access that class member
without instantiating an actual object first.

Hope this helps :o)

"patang" wrote:
When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be accessed
in the same fashion.. e.g.

myclass.myfunction("parameter")

Nov 21 '05 #4
I think you are talking about SHARED members. Triy using the SHARED keyword
when declaring your member. You should be able to access that class member
without instantiating an actual object first.

Hope this helps :o)

"patang" wrote:
When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be accessed
in the same fashion.. e.g.

myclass.myfunction("parameter")

Nov 21 '05 #5
"patang" <pa****@discussions.microsoft.com> schrieb:
When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be
accessed
in the same fashion..


There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #6
"patang" <pa****@discussions.microsoft.com> schrieb:
When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be
accessed
in the same fashion..


There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #7
Does this mean that LEFT or RIGHT functions (methods) are declared as SHARED
in the STRINGS class ?

"Herfried K. Wagner [MVP]" wrote:
"patang" <pa****@discussions.microsoft.com> schrieb:
When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be
accessed
in the same fashion..


There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #8
Does this mean that LEFT or RIGHT functions (methods) are declared as SHARED
in the STRINGS class ?

"Herfried K. Wagner [MVP]" wrote:
"patang" <pa****@discussions.microsoft.com> schrieb:
When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be
accessed
in the same fashion..


There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #9
I have one public function in the class and many private functions. Public
functions uses those private functions. When I declare the public function as
"SHARED" then I can't access the private function from within public
functions, it says: " ....Cannot refer to an instance member of a class from
within a shared method or shared member initializer without an explicit
instance of the class....."

"Herfried K. Wagner [MVP]" wrote:
"patang" <pa****@discussions.microsoft.com> schrieb:
When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be
accessed
in the same fashion..


There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #10
I have one public function in the class and many private functions. Public
functions uses those private functions. When I declare the public function as
"SHARED" then I can't access the private function from within public
functions, it says: " ....Cannot refer to an instance member of a class from
within a shared method or shared member initializer without an explicit
instance of the class....."

"Herfried K. Wagner [MVP]" wrote:
"patang" <pa****@discussions.microsoft.com> schrieb:
When I create my own class, to use the functions of that class I have to
create an object of that class and then I can access the functions of that
class,

for example:

dim obj1 as myclass
obj1 = new myclass
obj1.myfunction("parameter")

However, when I use .net class e.g. strings I do not need to create a
object, I can directly use it?

e.g.

x = strings.left("abc",2)

What do I have to do, so that the functions of my class can also be
accessed
in the same fashion..


There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #11
"Public Shared Function Left(ByVal str As String, ByVal Length As Integer)
As String
Member of Microsoft.VisualBasic.Strings"
- Microsoft documentation.

But there more classes with a method called 'Left'. And they can all do
other things. Check out the specific class for more info.

Does this mean that LEFT or RIGHT functions (methods) are declared as
SHARED
in the STRINGS class ?

"Herfried K. Wagner [MVP]" wrote:
"patang" <pa****@discussions.microsoft.com> schrieb:
> When I create my own class, to use the functions of that class I have
> to
> create an object of that class and then I can access the functions of
> that
> class,
>
> for example:
>
> dim obj1 as myclass
> obj1 = new myclass
> obj1.myfunction("parameter")
>
> However, when I use .net class e.g. strings I do not need to create a
> object, I can directly use it?
>
> e.g.
>
> x = strings.left("abc",2)
>
> What do I have to do, so that the functions of my class can also be
> accessed
> in the same fashion..


There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #12
"Public Shared Function Left(ByVal str As String, ByVal Length As Integer)
As String
Member of Microsoft.VisualBasic.Strings"
- Microsoft documentation.

But there more classes with a method called 'Left'. And they can all do
other things. Check out the specific class for more info.

Does this mean that LEFT or RIGHT functions (methods) are declared as
SHARED
in the STRINGS class ?

"Herfried K. Wagner [MVP]" wrote:
"patang" <pa****@discussions.microsoft.com> schrieb:
> When I create my own class, to use the functions of that class I have
> to
> create an object of that class and then I can access the functions of
> that
> class,
>
> for example:
>
> dim obj1 as myclass
> obj1 = new myclass
> obj1.myfunction("parameter")
>
> However, when I use .net class e.g. strings I do not need to create a
> object, I can directly use it?
>
> e.g.
>
> x = strings.left("abc",2)
>
> What do I have to do, so that the functions of my class can also be
> accessed
> in the same fashion..


There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #13
You have to make the 'Private' methods also 'Shared' if you want to use them
inside a 'Public Shared' method, or create an instance of the class inside
the 'Public Shared' instance and use that instance to call the 'Private'
methods.
"patang" <pa****@discussions.microsoft.com> schreef in bericht
news:64**********************************@microsof t.com...
I have one public function in the class and many private functions. Public
functions uses those private functions. When I declare the public function
as
"SHARED" then I can't access the private function from within public
functions, it says: " ....Cannot refer to an instance member of a class
from
within a shared method or shared member initializer without an explicit
instance of the class....."


"Herfried K. Wagner [MVP]" wrote:
"patang" <pa****@discussions.microsoft.com> schrieb:
> When I create my own class, to use the functions of that class I have
> to
> create an object of that class and then I can access the functions of
> that
> class,
>
> for example:
>
> dim obj1 as myclass
> obj1 = new myclass
> obj1.myfunction("parameter")
>
> However, when I use .net class e.g. strings I do not need to create a
> object, I can directly use it?
>
> e.g.
>
> x = strings.left("abc",2)
>
> What do I have to do, so that the functions of my class can also be
> accessed
> in the same fashion..


There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #14
You have to make the 'Private' methods also 'Shared' if you want to use them
inside a 'Public Shared' method, or create an instance of the class inside
the 'Public Shared' instance and use that instance to call the 'Private'
methods.
"patang" <pa****@discussions.microsoft.com> schreef in bericht
news:64**********************************@microsof t.com...
I have one public function in the class and many private functions. Public
functions uses those private functions. When I declare the public function
as
"SHARED" then I can't access the private function from within public
functions, it says: " ....Cannot refer to an instance member of a class
from
within a shared method or shared member initializer without an explicit
instance of the class....."


"Herfried K. Wagner [MVP]" wrote:
"patang" <pa****@discussions.microsoft.com> schrieb:
> When I create my own class, to use the functions of that class I have
> to
> create an object of that class and then I can access the functions of
> that
> class,
>
> for example:
>
> dim obj1 as myclass
> obj1 = new myclass
> obj1.myfunction("parameter")
>
> However, when I use .net class e.g. strings I do not need to create a
> object, I can directly use it?
>
> e.g.
>
> x = strings.left("abc",2)
>
> What do I have to do, so that the functions of my class can also be
> accessed
> in the same fashion..


There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #15
one more question:

In my solution only following are imported:

System
System.Data
System.Drawings
System.Windows.Form
System.XML

System.Data.Oledb

How come the methods of Strings class are accessible even though it has not
been imported in my solution?

"Qwert" wrote:
You have to make the 'Private' methods also 'Shared' if you want to use them
inside a 'Public Shared' method, or create an instance of the class inside
the 'Public Shared' instance and use that instance to call the 'Private'
methods.
"patang" <pa****@discussions.microsoft.com> schreef in bericht
news:64**********************************@microsof t.com...
I have one public function in the class and many private functions. Public
functions uses those private functions. When I declare the public function
as
"SHARED" then I can't access the private function from within public
functions, it says: " ....Cannot refer to an instance member of a class
from
within a shared method or shared member initializer without an explicit
instance of the class....."


"Herfried K. Wagner [MVP]" wrote:
"patang" <pa****@discussions.microsoft.com> schrieb:
> When I create my own class, to use the functions of that class I have
> to
> create an object of that class and then I can access the functions of
> that
> class,
>
> for example:
>
> dim obj1 as myclass
> obj1 = new myclass
> obj1.myfunction("parameter")
>
> However, when I use .net class e.g. strings I do not need to create a
> object, I can directly use it?
>
> e.g.
>
> x = strings.left("abc",2)
>
> What do I have to do, so that the functions of my class can also be
> accessed
> in the same fashion..

There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Nov 21 '05 #16
I'm guessing because you have "Microsoft.VisualBasic" in your import
statements of your project.

Right click on your project's name in the solution explorer and click on
properties. Select Common Properties -> Imports. There is a list with
Project Imports.

"patang" <pa****@discussions.microsoft.com> schreef in bericht
news:9E**********************************@microsof t.com...
one more question:

In my solution only following are imported:

System
System.Data
System.Drawings
System.Windows.Form
System.XML

System.Data.Oledb

How come the methods of Strings class are accessible even though it has
not
been imported in my solution?

"Qwert" wrote:
You have to make the 'Private' methods also 'Shared' if you want to use
them
inside a 'Public Shared' method, or create an instance of the class
inside
the 'Public Shared' instance and use that instance to call the 'Private'
methods.
"patang" <pa****@discussions.microsoft.com> schreef in bericht
news:64**********************************@microsof t.com...
>I have one public function in the class and many private functions.
>Public
> functions uses those private functions. When I declare the public
> function
> as
> "SHARED" then I can't access the private function from within public
> functions, it says: " ....Cannot refer to an instance member of a class
> from
> within a shared method or shared member initializer without an explicit
> instance of the class....."

>
>
>
> "Herfried K. Wagner [MVP]" wrote:
>
>> "patang" <pa****@discussions.microsoft.com> schrieb:
>> > When I create my own class, to use the functions of that class I
>> > have
>> > to
>> > create an object of that class and then I can access the functions
>> > of
>> > that
>> > class,
>> >
>> > for example:
>> >
>> > dim obj1 as myclass
>> > obj1 = new myclass
>> > obj1.myfunction("parameter")
>> >
>> > However, when I use .net class e.g. strings I do not need to create
>> > a
>> > object, I can directly use it?
>> >
>> > e.g.
>> >
>> > x = strings.left("abc",2)
>> >
>> > What do I have to do, so that the functions of my class can also be
>> > accessed
>> > in the same fashion..
>>
>> There are two ways to archieve what you want to do:
>>
>> * You can add the 'Shared' modifier to your function when
>> it's part of a class ('Public Shared Function...').
>>
>> * Or you can add the function to a module. 'Shared' is not
>> required when doing this. Functions defined in modules
>> are imported automatically and thus can be accessed
>> with their unqualified name (for example, 'Left' instead of
>> 'Strings.Left').
>>
>> --
>> M S Herfried K. Wagner
>> M V P <URL:http://dotnet.mvps.org/>
>> V B <URL:http://classicvb.org/petition/>
>>
>>


Nov 21 '05 #17

Your are right. "Microsoft.VisualBasic" is included in the list of imports
in my project.
"Qwert" wrote:
I'm guessing because you have "Microsoft.VisualBasic" in your import
statements of your project.

Right click on your project's name in the solution explorer and click on
properties. Select Common Properties -> Imports. There is a list with
Project Imports.

"patang" <pa****@discussions.microsoft.com> schreef in bericht
news:9E**********************************@microsof t.com...
one more question:

In my solution only following are imported:

System
System.Data
System.Drawings
System.Windows.Form
System.XML

System.Data.Oledb

How come the methods of Strings class are accessible even though it has
not
been imported in my solution?


Nov 21 '05 #18
"patang" <pa****@discussions.microsoft.com> schrieb:
Does this mean that LEFT or RIGHT functions (methods) are declared as
SHARED
in the STRINGS class ?


These functions are declared in the 'Strings' /module/. Methods declared in
a module are implicitly shared.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #19
I'm not 100% clear about what you mean... I understand completely about
having a public shared function in a class (I use one in a singleton
pattern class to hold some global variables). However, when I access that
function I need to fully qualify it (ie: myClass.myfunction() ). On your
second point, I'm not quite sure what you mean by adding the function to a
module.

I have a custom control library which I've built into a DLL. It contains
various *.VB files and each VB file has 1 or more classes defined. These
classes have public subs which I can access with the fully qualified name
(myClass.mySub). I do an IMPORT of this library dll wherever I need it.

What I would like to do is create a sub in this library that I can reference
without having to fully qualify it. It doesn't particularly matter if this
sub is in a class or not, I'd just like to be able to say
"myFunction(...)" without qualification (assume the name is unique).

Is there a way to do this?

Thanks, John

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OV**************@TK2MSFTNGP09.phx.gbl...
There are two ways to archieve what you want to do:

* You can add the 'Shared' modifier to your function when
it's part of a class ('Public Shared Function...').

* Or you can add the function to a module. 'Shared' is not
required when doing this. Functions defined in modules
are imported automatically and thus can be accessed
with their unqualified name (for example, 'Left' instead of
'Strings.Left').

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #20
"JohnR" <Jo******@hotmail.com> schrieb:
I'm not 100% clear about what you mean... I understand completely about
having a public shared function in a class (I use one in a singleton
pattern class to hold some global variables). However, when I access that
function I need to fully qualify it (ie: myClass.myfunction() ). On your
second point, I'm not quite sure what you mean by adding the function to a
module.

I have a custom control library which I've built into a DLL. It contains
various *.VB files and each VB file has 1 or more classes defined. These
classes have public subs which I can access with the fully qualified name
(myClass.mySub). I do an IMPORT of this library dll wherever I need it.

What I would like to do is create a sub in this library that I can
reference without having to fully qualify it. It doesn't particularly
matter if this sub is in a class or not, I'd just like to be able to say
"myFunction(...)" without qualification (assume the name is unique).

Is there a way to do this?

Add an additional file to your class library:

\\\
Public Module CommonFunctions
Public Sub DoSomething()
...
End Sub
End Module
///

In the project that uses the DLL import the DLL's root namespace
('ClassLibrary1'). Then you will be able to call 'DoEvents' without
qualification. If you are using a class instead of the module

\\\
Public Class CommonFunctions
Public Shared Sub DoSomething()
...
End Sub
End Class
///

and import the class in the client project that uses the DLL ('Imports
ClassLibrary1.CommonFunctions') you will be able to call 'DoSomething'
without fully qualifying it too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #21
Herfried,

I was writing as well an answer on the question when I saw yours.

You can for sure interpret my message wrong, therefore this message.

My message about shared and non shared is *not* based on your message. I had
already written it before that I saw yours.

Cor
Nov 21 '05 #22
Herfried,

I readed this while busy for a sample about
"Set Controls dinamically? is this for experts?"

and thought that this was your answer on that, so forget it.

Sorry

Cor
Nov 21 '05 #23
Herfried,

Thank you so much for your response. It worked out very well. The
thing I was missing was not realizing that you could do a:

Imports ClassLibrary.CommonFunctions

I thought you could only import the ClassLibrary itself... You really
cleared it up for me...

Thanks again, John

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
"JohnR" <Jo******@hotmail.com> schrieb:
I'm not 100% clear about what you mean... I understand completely about
having a public shared function in a class (I use one in a singleton
pattern class to hold some global variables). However, when I access
that function I need to fully qualify it (ie: myClass.myfunction() ).
On your second point, I'm not quite sure what you mean by adding the
function to a module.

I have a custom control library which I've built into a DLL. It contains
various *.VB files and each VB file has 1 or more classes defined. These
classes have public subs which I can access with the fully qualified name
(myClass.mySub). I do an IMPORT of this library dll wherever I need it.

What I would like to do is create a sub in this library that I can
reference without having to fully qualify it. It doesn't particularly
matter if this sub is in a class or not, I'd just like to be able to say
"myFunction(...)" without qualification (assume the name is unique).

Is there a way to do this?

Add an additional file to your class library:

\\\
Public Module CommonFunctions
Public Sub DoSomething()
...
End Sub
End Module
///

In the project that uses the DLL import the DLL's root namespace
('ClassLibrary1'). Then you will be able to call 'DoEvents' without
qualification. If you are using a class instead of the module

\\\
Public Class CommonFunctions
Public Shared Sub DoSomething()
...
End Sub
End Class
///

and import the class in the client project that uses the DLL ('Imports
ClassLibrary1.CommonFunctions') you will be able to call 'DoSomething'
without fully qualifying it too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fernando Rodriguez | last post by:
Hi, I need to traverse the methods defined in a class and its superclasses. This is the code I'm using: # An instance of class B should be able to check all the methods defined in B #and A,...
18
by: John M. Gabriele | last post by:
I've done some C++ and Java in the past, and have recently learned a fair amount of Python. One thing I still really don't get though is the difference between class methods and instance methods. I...
1
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me...
13
by: Bryan Parkoff | last post by:
I have created three classes according to my own design. First class is called CMain. It is the Top Class. Second class and third class are called CMemory and CMPU. They are the sub-classes....
9
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
8
by: Bryan Parkoff | last post by:
I find an interesting issue that one base class has only one copy for each derived class. It looks like that one base class will be copied into three base classes while derived class from base...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.