Link to home
Start Free TrialLog in
Avatar of Centripetal
Centripetal

asked on

ASP problem with COM

I'm writing a COM for ASP. I want to return an array, so I return in a Variant, and it returns fine.  But the VBScript will not let me subscript the returned array.   I used, TypeName, IsArray, UBound, and LBound, and all are saying it's an array.  Just gives me type mismatch when I try subscripting it.
Avatar of robbert
robbert

Better post the code.
I'm guessing that you're probably returning an array of some type in a variant.  Try returning an array of variants-- as opposed to an array of strings in a variant, for example.


E.g.,

Example1 won't work.  VBScript will give you a type-mismatch when you try to access an array member.  UBound, LBound, IsArray will all work-- it's returning a SafeArray, but the items within it are typed, so VBScript complains.

function example1() as variant

  dim s(1) as string
  s(0) = "hello"
  s(1) = "there"
  example1 = s

end function


Instead try this:

function example2() as variant
   dim s(1) as variant
   s(0) = "hello"
   s(1) = "there"
   example2 = s
end function
Avatar of Centripetal

ASKER

That did it Clockwatcher, that you very much for the help.
ASKER CERTIFIED SOLUTION
Avatar of clockwatcher
clockwatcher

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Answer accepted