By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,768 Members | 1,151 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,768 IT Pros & Developers. It's quick & easy.

Calling a "Public Shared" VB.NET function from VB6?

P: n/a
(I previously posted this problem on vb.general.discussion but I've been told
that this question is more related to VB.NET than VB6 and so that I should
post that here.)
I'm trying to call a "Public Shared" function in a dll built in VB.NET from a
VB6 program.

Whenever I try, I get an error saying that the function doesnt exist. I had
doubts that the "Shared" in the VB.NET dll could be the problem. I tried to
recompile the dll without the "Shared" and I can now call it from VB6 without
problem. It's as if the "Shared" made it so VB6 could no longer communicate
with the DLL, as if the function wasnt existing at all from the VB6 point of
view.
Is there a way to call a "Shared" VB.NET function from VB6?
(Right now I have two workarounds that I dont really like:
1- Remove the "Shared" from the function
2- Make an intermediate VB.NET dll whose sole purpose is to call the
"Shared" function of the other VB.NET dll)
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
I dont think you will be able to do it because VB6 is calling the VB.NET dll
via COM (via interop) and AFAIK there is no such thing as "static" methods
in VB6/COM, so it likely just doesnt know how to call anything that is not
related to a particular instance of the class.

I hope that makes sense, I have had little sleep.
"David Sanschagrin" <Da**************@discussions.microsoft.com> wrote in
message news:F7**********************************@microsof t.com...
(I previously posted this problem on vb.general.discussion but I've been
told
that this question is more related to VB.NET than VB6 and so that I should
post that here.)
I'm trying to call a "Public Shared" function in a dll built in VB.NET
from a
VB6 program.

Whenever I try, I get an error saying that the function doesnt exist. I
had
doubts that the "Shared" in the VB.NET dll could be the problem. I tried
to
recompile the dll without the "Shared" and I can now call it from VB6
without
problem. It's as if the "Shared" made it so VB6 could no longer
communicate
with the DLL, as if the function wasnt existing at all from the VB6 point
of
view.
Is there a way to call a "Shared" VB.NET function from VB6?
(Right now I have two workarounds that I dont really like:
1- Remove the "Shared" from the function
2- Make an intermediate VB.NET dll whose sole purpose is to call the
"Shared" function of the other VB.NET dll)

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.