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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a dynamic multidimensional array from an ASP page to a VB COM

Status
Not open for further replies.
Jan 30, 2002
44
CA
Does any one have an sample code of passing a dynamic multidimensional array from an ASP page to a VB COM object? Can you please help me thanks...
 
COM:

public function giveMeAnArray(someArray AS Variant)
'do something with it here
end function

ASP:
dim myObj, myArray, dimensions, elements
set myObj = server.createObject("ProjectName.ClassName")

dimensions = 2
elements = 5
redim myArray(dimensions,elements)

myObj.giveMeAnArray(myArray)

-----
note that I did not specify in the COM function that it was an array. If you're calling that function from a strongly typed language (which vbScript is not), then you might want to declare the function:

(someArray() AS Integer)

or whatever... specifying that it is an array with (), and specifying what datatype it is with 'AS Integer'. Using it from vbScript(ASP), though, you must declare it as I have shown, or you will get type mismatch, even if you say:

(someArray() AS Variant)

The object still cannot see your argument as an array, and will return the 'type mismatch' error to your page.

hope that helps! :)
paul
penny1.gif
penny1.gif
 
I spent days a few years ago sorting the problem of passing an array to VB.
In VB and VBScript there are two types of arrays involved with variants.
The first is an Array of Variants i.e. it is an array first that contains variants e.g.
Dim aryVar() '
This type of array can not be passed to VB.

The second is a Variant that contains an Array i.e. it is Variant first with an array stored in it e.g.
Dim varary
Redim varary(20)
This type can be passed to VB.

As far as VBScript coding is concerned, there is no real difference until you start storing an array into an element of an existing array and begin using sytax like
aryvar(0)(1) which gets the 2nd element of the array stored in the first element of the aryvar array. It can boggle the mind quickly. Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top