We help IT Professionals succeed at work.

Passing data from VB6 ActiveX EXE to ASP - including arrays

Medium Priority
Last Modified: 2008-01-09
Hi, all,
I have an ASP which calls procedures in an ActiveX EXE.  It needs to be an EXE not a DLL because it will be running on a server, and called by many different ASP instances, and data needs to be preserved between ASP instances.
The ASP procs seem to be calling the EXE procs OK, but I'm not getting data returned in the parameters.  They remain as they were before the call.  The parameters are usually either strings or arrays of strings.  What am I doing wrong, please?  Should I have a thin ActiveX Dll between the ASP and the EXE? or is there a simpler solution?
Watch Question

Have you tried making your parameters Variant?  I had problems like this before, mostly because of the typeless nature of VBScript.


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Is this running on a windows server.

There are problems with Activex EXE. I thik that when an object is create the exe server starts, when the object is noloinger required the exe will die so you loose you data between calls. You can prevent this by making the first time an object is create the activex exe itself creates a global instance of an object, in this way when the calling object dies, the exe will stay running.

However, normally in IIS you can use the application object to store any kind of data you wish.....
If Not IDE Then
End If
Application("MyData") = "MyStuff"
If Not IDE Then
End If

The lock and unlock are really only needed when updating counters. But warning if you are running in the IDE you must not issue Lock/Unlock as there is a bug that causes IIS to hang. If you do not have an IDE funciton I can post the code.

You can also use the session object to keep data from a particular client. Saving and loading specific user files is also pretty fast too.  But the session object works like this:

Session("MyClientStuff") = "Stuff just for one client"

When using the ssession object it is also possible to give the client a unique ID so you can retain and  access data between sessions.

The advantage of doing this is you can create a VB DLL and pass the IIS objects to the VB DLL.  Doing things this way you don't need to pass any data back to the asp object. And you cann create a really solid robust app. And that is just what every body wants after all is said and done.

Here is an example ASP page that also addresses the issue of debugging ActiveX DLL & EXE.

1) In this example the project name is VIPASP110, when compiled I create VIPASP110.DLL
2) After each compile I change the project name to VIPASP111
    And  I edit the debug launch browser qurity string http://MyServe/MyAsp.asp?ver=111

Option Explicit
Response.Buffer = True

On Error Resume Next

Dim ProgID

ProgID = Cstr(Session("ProgID"))
If Len(ProgID) = 0 Then
    ProgID = Request.QueryString("Ver")
    Session("ProgID") = ProgID
End If

if Len(ProgID) = 0 Then
No progID specified in the query string. Change debug to ?ver=110
End If

Set VIP=Server.CreateObject("vipasp" & ProgID & ".Pager")

If Err.number<>0 Then
      Response.write "Error: " & err.description & "<BR>"
      Response.write "Number: " & cstr(err.number) & "<BR>"
         ' register the IIS objects in the DLLs object
      VIP.Register Server, Request, Response, Application, Session
If Err.number<>0 Then
            Response.write "Error: " & err.description & "<BR>"
            Response.write "Number: " & cstr(err.number) & "<BR>"
        end if
End If
Set VIP = Nothing

If you want more code examples and suggestions of how you can write the code so you can make it real quick to create a new VB DLL to be handled by and ASP page just ask.


Hi, Taconvino,
I am in the process of changing to variants - I had (being a good programmer and all) everything typed, but found some hints in the Web suggesting that I need to use variants.  Not sure yet whether that helps - but thanks for your comment - it makes me hopeful that the problem is using types.

Hi, InTheDark,
The ASP, some of the HTM files and the ActiveX files are all server-side.  I have to keep data between different callers, and the way I have done this is by using collections.  The ActiveX exe has a class which is the interface.  In the ActiveX is a collection (declared in a module (.BAS) file) of objects of another class in the ActiveX exe - this has all the real properties and methods..  The inteface class is (I hope) instantiated by being called by the .ASP.  When it is instantiated it may add a new member of the collection (the first call gives an identifer, which should be unique, and is the key for the collection).  The collection member is an object of the underlying class - the one that really does the work, holds the data etc. - so the interface then calls the appropriate properties of the appropriate instance.  That may not be clear, I'm afraid.  I have tested this with a VB Exe acting asthe front end, and it works fine.

The problem now seems to come down to passing variables back and forth.  Well, the ActiveX is getting the appropriate values in the parameters, but is not passing data back properly.

I am currently suffering another problem.  I wanted to have a really simple test-bed - HTM, ASP and ActiveX, the former two cut right down to the minimum.  They are all on the same computer.  However, I seem unable to create an object:

            <script type="text/javascript" language="JavaScript" src="../_ScriptLibrary/rs.htm"></script>
            <script type="text/javascript" language="JavaScript">RSEnableRemoteScripting("../_ScriptLibrary");</script>
            <script type="text/vbscript" language="VBScript">

dim StevesNamPro

Sub window_OnLoad()
   set StevesNamPro = RSGetASPObject ("C:\Inetpub\wwwroot\NavyNet\StevesNamPro.asp")
end sub

The RSGetASPObject fails - I get
Failed to to create ASP object for: 'C:\Inetpub\wwwroot\NavyNet\StevesNamPro.asp'
reported by the HTM, and
Object Required: RSGetASPObject('...')
in the debugger.

I guess that I don't actually need a remote thing - they are all on the same machine - but a) I don't know why this fails anyway, and b) I'm not sure what I need to do to use a local object creation.


Wow you do make it hard for yourself. Why not save your collections in the Session and Global objects?


Hi, inthedark,
:-)  I didn't realist I was making it hard for myself.  could you expand on what you mean by the Session and Global objects, please?
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.