473,767 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

(I previously posted this problem on vb.general.disc ussion 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 6782
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******** *************** ***********@mic rosoft.com...
(I previously posted this problem on vb.general.disc ussion 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
8867
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
2673
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 Access 2.0 module. I was unsuccessful. I had to remove the following... "Public" "Optional ByRef" "As Boolean"
15
12565
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 you need to pass "Me" to the public function in a module? I've tried calling Public Function libComboFilter(frmForm As Form_Form1) As String
4
5361
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 calling it from each form. Trouble is, the code uses the "Me" keyword throughout to refer to data objects and I can't quite fathom out how to pass it to my function and how to handle it once it's there. Any pointers?
4
2394
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 runat="server" Text='<%# DecryptString(DataBinder.Eval(Container, "DataItem.Password")) %>' /> </ItemTemplate>
3
1533
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 FewsArticles(OrgID As String) As String'." Here's the client calling code: Dim sFeed As String = oWs.FewsArticles(OrgID, FeedType)
1
23256
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 Shared (available without having to instantiate a class). So how could a Private Shared Function be called? Why give it this particular scope?
15
9603
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 class, I can call it from the form, but if I define public function in the form and try to call it from the class it does not work. Any idea what am I doing wrong? Thanks,
5
4907
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 Protect As Boolean End Type Public Function FnName() Dim Var1 as TypeName Dim Var2 as TypeName
0
9575
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9407
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10170
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9960
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9841
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7384
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3534
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2808
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.