Call the same class from an VB exe and from an asp

I want to use the same class from vb exe application and from asp.
To use it in the exe application the class should be private class, and to use it from the asp (as an ActiveX) the class should be public (multi use).
Any solution?
Who is Participating?
caraf_gConnect With a Mentor Commented:
A silly workaround, but it works.

You quite rightly point out that a class in an .exe has to be private, whereas in a DLL or anything else it can be public.

If you want to use the same class module both in a DLL and in an EXE (and you want to make it public in the DLL) you have a problem.

The best solution is to leave it private, and to write a public "wrapper" class around the private one:

Your public wrapper class

General declarations:
Private MyPrivateClassObject As YourPrivateClass

In Class_Initialize()
    Set MyPrivateClassObject = New YourPrivateClass

In Class_Terminate()
    Set MyPrivateClassObject = Nothing

And any property or method:
Public Property Get MyProperty() As SomeType
    MyProperty = MyPrivateClassObject.MyProperty


Public Sub DoSomething(SomeParameters As SomeTypes)
    MyPrivateClassObject.DoSomething SomeParameters


Clumsy, but it works.
efrataltshulerAuthor Commented:
Edited text of question.
Éric MoreauSenior .Net ConsultantCommented:
Compile an ActiveX (DLL or EXE) which will contain your class instantiated as public multi-use (if this what you want).

Don't forget to references the DLL in your VB application!

Then you will be able to access your class from both application.
efrataltshulerAuthor Commented:
This is the simple solution. but I want to use many class in both the VB exe application and the ASP and some of the class are shared to some other vb applications and I don't want to create an ActiveX dll for each class (or group of classes).
Éric MoreauSenior .Net ConsultantCommented:
You can create one ActiveX that includes every classes that you have!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.