472,995 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,995 software developers and data experts.

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 1675
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.