Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass array from vb dll to ASP...?

Status
Not open for further replies.

sunaj

Technical User
Feb 13, 2001
1,474
DK
Hi,

I'm having problems passing an array from my vb dll to ASP.
My vb code looks like:

-----------------------------------------------------
Option explicit
Public Function AddStationArr(Stations As Variant) As Variant
Dim ArrTmp() as integer
'some code here using Stations. Stations is a ADODB.recordset, but it only works when I Declare is as variant.
ReDim ArrTmp(1,0)
'some code incl. a loop with Redim preserve ArrTmp
AddStationArr = ArrTmp
end function
-----------------------------------------------------

My asp code:
-----------------------------------------------------
Option explicit
dim Draw, ArrTmp, rst

Set Draw = server.createobject(Myproject.MyClass)
set rst = server.createobject(ADODB.recordset)
'some code here
ArrTmp = Draw.AddStationRst(rst)
'ArrTmp Does not contain an array here! It contains an unknown datatype. If I try to: ArrTmp(0,0) I get and error: "ArrTmp: Unknown datatype."
-----------------------------------------------------

What am I doing wrong?

Sunaj
 
You are trying to pass an array of integer to a variant.
Try this
Dim ArrTmp as variant 'WITHOUT PARENS
The Redim will make it a Variant containig an array.
Dim ArrTmp() as variant is an array of variants and is a different animal because it is an array first and you need a variant first containing an array.
 
U r using a method name which is different from one written in VB dll
chik it
 
Hi, John

I've tried this and it works when I use it from Vb (and so did the Dim ArrTmp() as integer), but it does not work when I try to use it from ASP.

----------------------------------------------------------
Public Function ReturnArray(MyInput As String) As Variant
Dim ArrTmp As Variant

ReDim ArrTmp(1, 4)
ArrTmp(0, 0) = MyInput
ReturnArray = ArrTmp

End Function
----------------------------------------------------------

Anyway I made it like:
----------------------------------------------------------
Public Sub ReturnArray1(MyInput As String, Optional ReturnArr As Variant = "")

If IsArray(ReturnArr) Then
ReDim ReturnArr(1, 4)
ReturnArr(0, 0) = MyInput
End If

End Sub
----------------------------------------------------------

Which works from ASP and it's actually a better solution to my problem - but its still anoying that I can figure out how to return an array from a function call. So if you find the solution let me know.....

Sunaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top