473,471 Members | 4,648 Online
Bytes | Software Development & Data Engineering Community
Create 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("SomeName"
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 1693
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*******@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.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("SomeName")
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*******@discussions.microsoft.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("SomeName")
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*******@discussions.microsoft.com> wrote in message
news:EC**********************************@microsof t.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("SomeName")
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
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 (???)....
1
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...
7
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,...
13
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...
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
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,...
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
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.