Passing data from VB6 ActiveX EXE to ASP - including arrays

Posted on 2007-07-20
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?
Question by:BeachcomberSoftware
    LVL 6

    Accepted Solution

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

    LVL 17

    Expert Comment

    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.

    Author Comment

    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.

    LVL 17

    Expert Comment

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

    Author Comment

    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?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now