473,395 Members | 1,422 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,395 software developers and data experts.

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

(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
1 6749
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: BlueDoze | last post by:
I want to know the difference between the following 3 methods of calling a public function, which method is better and why method 1: myClass::myFunction(); method 2: myClass myObject;
4
by: MLH | last post by:
The following function declaration confuses me... Public Function IsEMailAddress(ByVal sEmail As String, Optional ByRef sReason As String) As Boolean I tried pasting it and its code into an...
15
by: Keith | last post by:
A97, NT4. I've seen an example of this posted here but I can't for the life of me find it. If I have a lot of controls on a form which all require the same After Update action, what syntax do...
4
by: Keith | last post by:
A2003, XP Pro. I have a VBA routine that I use to record data transactions in a history table. I'd like to use this routine for every form in my app by putting it in a public function and...
4
by: hansiman | last post by:
isn't it possible to call a public shared function that resides in another file directly from the datagrid html code?: <asp:TemplateColumn HeaderText="Password"> <ItemTemplate> <asp:Label...
3
by: DC Gringo | last post by:
I have a simple function within a web method. It works fine with one parameter, but gives me a compile error when I try to add a second: "Too many arguments to 'Public Function...
1
by: Edward | last post by:
I have trouble with some of the concepts of OOP, and am struggling currently with Private Shared Functions. I think I understand Private (not available outside the class). I think I understand...
15
by: Strahimir Antoljak | last post by:
Why can't I call a public function or sub defined in the main form of my application from within a module or a class, all being a part of the same assembly? When I define public function in a...
5
by: peter1234 | last post by:
Could you please confirm if 'Public Type', as defined below, is possible with Access 2003. Symilar example found in a book for Access 2007. Public Type TypeName Type as String Temp as Single ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.