473,652 Members | 2,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Expose overloaded constructors in Access2003

I built a class in VB.NET that has an overloaded constructor. It can either accept nothing, a string or an object

Public Sub New(
MyBase.New(
End Su

Public Sub New(ByVal strName As String
MyBase.New(
'... Do init with strNam
End Su

Public Sub New(ByVal oObj As MyObjClass
MyBase.New(
'... Do init with oOb
End Su

If I enter these lines in Access
dim x as MyClas
set x = new MyClass("SomeNa me"
then I get an error

How can I expose all constructors of my class in Access2003 or VB6

All help will be very much appreciated

Ver

Nov 20 '05 #1
3 1704
Hey Vera,

My experience is limited in this area, but doesn't Access 2003 only support
VBA? If so, do you have to expose your VB.NET class to COM at that point?

Again, not sure, but we were doing some GP work a little bit ago and had to
expose some .NET classes to COM to get it to work with VBA.

Hope it helps some,
CJ
"Vera" <an*******@disc ussions.microso ft.com> wrote in message
news:EC******** *************** ***********@mic rosoft.com...
I built a class in VB.NET that has an overloaded constructor. It can either accept nothing, a string or an object:
Public Sub New()
MyBase.New()
End Sub

Public Sub New(ByVal strName As String)
MyBase.New()
'... Do init with strName
End Sub

Public Sub New(ByVal oObj As MyObjClass)
MyBase.New()
'... Do init with oObj
End Sub

If I enter these lines in Access:
dim x as MyClass
set x = new MyClass("SomeNa me")
then I get an error.

How can I expose all constructors of my class in Access2003 or VB6?

All help will be very much appreciated!

Vera

Nov 20 '05 #2
* "=?Utf-8?B?VmVyYQ==?=" <an*******@disc ussions.microso ft.com> scripsit:
I built a class in VB.NET that has an overloaded constructor. It can either accept nothing, a string or an object:

Public Sub New()
MyBase.New()
End Sub

Public Sub New(ByVal strName As String)
MyBase.New()
'... Do init with strName
End Sub

Public Sub New(ByVal oObj As MyObjClass)
MyBase.New()
'... Do init with oObj
End Sub

If I enter these lines in Access:
dim x as MyClass
set x = new MyClass("SomeNa me")
then I get an error.

How can I expose all constructors of my class in Access2003 or VB6?


How do you use the .NET Class inside Access? If you are using VBA, I
seriously doubt that you can use parameterized ctors.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
Vera,
How can I expose all constructors of my class in Access2003 or VB6? Short answer: You don't.

Long answer: You can't as Access 2003 is COM based, COM does not support
overloading methods, nor does it support any constructors other then the
default constructor.

What you may want to do is to create a Factory Class (a second class) that
has two methods on it that create your first class based on a string or
based on an object.

Hope this helps
Jay

"Vera" <an*******@disc ussions.microso ft.com> wrote in message
news:EC******** *************** ***********@mic rosoft.com... I built a class in VB.NET that has an overloaded constructor. It can either accept nothing, a string or an object:
Public Sub New()
MyBase.New()
End Sub

Public Sub New(ByVal strName As String)
MyBase.New()
'... Do init with strName
End Sub

Public Sub New(ByVal oObj As MyObjClass)
MyBase.New()
'... Do init with oObj
End Sub

If I enter these lines in Access:
dim x as MyClass
set x = new MyClass("SomeNa me")
then I get an error.

How can I expose all constructors of my class in Access2003 or VB6?

All help will be very much appreciated!

Vera

Nov 20 '05 #4

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

Similar topics

1
2374
by: andrea_gavana | last post by:
Hello NG, I am trying to port a useful class from wxWidgets (C++) to a pure Python/wxPython implementation. In the C++ source code, a unique class is initialized with 2 different methods (???). This is what it seems to me. I have this declarations: class wxFoldWindowItem { private: wxWindow *_wnd;
1
2219
by: masood.iqbal | last post by:
I have a few questions regarding overloaded typecast operators and copy constructors that I would like an answer for. Thanks in advance. Masood (1) In some examples that I have seen pertaining to casting class A to class B, the implementation of the
7
1492
by: cmay | last post by:
Can someone quick shed some light on this issue I am having? I wanted to create 2 constructors for my object, one that takes an ID value and one that takes a datarow. If ID value is provided, it is going to get the info from the database and populate itself. If a datarow is provided, then it will use the row to populate itself. So, I wanted to have the "by ID" function get a datarow from the
13
1503
by: =?Utf-8?B?QW5kcmVhcw==?= | last post by:
Hi, I would like to get some thoughts on Overloaded constructors vs. Object initializations. Assuming that the class supports a default constructor, is there any reason to include overloaded constructors when you are able to use object initialization? I see a point, to provide the overloads, if you are developing framework code that might support the need to run ontop of 2.x but if you are writing a sealed application / know you are...
0
8367
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
8279
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
8703
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8467
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
8589
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
6160
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
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.