By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,728 Members | 1,145 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,728 IT Pros & Developers. It's quick & easy.

Expose overloaded constructors in Access2003

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
* "=?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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.