ASP, COM and Array

Results 1 to 5 of 5

Thread: ASP, COM and Array

  1. #1
    Dilip Guest

    Default ASP, COM and Array

    Hi,<BR><BR>01. I need to write a function ( in VB activex dll ) which returns an array .<BR><BR>02. Call this function from an ASP and assign the array returned by this dll to an array defined in asp.<BR><BR>Anybody did this type of logic? I&#039;m wondering how to implement this.<BR><BR>Thanks<BR>Dilip

  2. #2
    Steve Cimino Guest

    Default RE: ASP, COM and Array

    Public Function Whatever() As Variant<BR>&#039;code code code<BR>Whatever = myArray()<BR><BR>End Function<BR><BR>ASP:<BR><BR>Dim x<BR><BR>x = myCOMObject.Whatever<BR><BR>x now contains your array.<BR><BR><BR><BR>You can return an array also, but until VB.NET, it&#039;s simpler to use the variant type (variants are going away with the next version of VB).

  3. #3
    Dilip Guest

    Default RE: ASP, COM and Array

    Steve,<BR><BR>I created activex dll in vb5 with following code:<BR>Option Explicit<BR><BR>Public Function process() As Variant<BR><BR> Dim arr1() As String<BR> ReDim arr1(2)<BR><BR> arr1(0) = "header1"<BR> arr1(1) = "header2"<BR> arr1(2) = "header3"<BR><BR> process = arr1<BR><BR>End Function<BR><BR>In in asp I used following code :<BR>&#060;%<BR><BR>dim array1<BR><BR>set obj = Server.CreateObject("Project1.class1")<BR>set array1 = obj.process()<BR><BR>Response.Write(array1(0))<BR> <BR>%&#062;<BR><BR>I&#039;m getting following error :<BR>Microsoft VBScript runtime error &#039;800a01a8&#039; <BR><BR>Object required <BR><BR>/Project2/display.asp, line 13<BR><BR>

  4. #4
    Steve Cimino Guest

    Default RE: ASP, COM and Array

    Change this:<BR><BR>set array1 = obj.process()<BR><BR>to this:<BR><BR>array1 = obj.process()<BR><BR>You don&#039;t want to &#039;set&#039; the array to anything.<BR><BR>Also, when returning the array (in VB6 at least) you should do:<BR><BR>myFunction = myArray() &#039;notice the parens<BR><BR>if this still gives you grief, declare the array as an array of variants instead of an array of strings -- I&#039;ve seen problems with that in IIS4, at least.<BR>

  5. #5
    cl Guest

    Default RE: ASP, COM and Array

    this is cl from the other forum. I understand your code here. <BR>1. how can I get the values from x obj in ASP? Can I use x(a,b)?<BR>2. Does this work for a multi-dimensional array? <BR>3. can I use x.recordcount if I want to find out the max number of elements in this array?<BR><BR>THANKS!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts