still looking for real solution to VBScript->C# array params

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Christopher Robert (chrislrobert_at_hotmail.com)
Date: 06/06/04


Date: Sun, 6 Jun 2004 19:07:57 +0700

This problem appears to be common, but I haven't yet seen a real solution:
you want to pass an array from VBScript into a C#-built COM object. People
say to declare the incoming array param as an object rather than an array --
but when you do so (either "object" or "ref object") you're treated to a
curious "variable uses an automation type not supported in VBScript" error.
If you go with "object[]" or "string[]" you get "invalid procedure call or
argument" instead.

Kudos to Odie for discovering that an extra pair of ()'s around the
parameter on the VBscript side gets around the error. Kudos also to
Alexander for determining that passing an Array(x,y,z) parameter somehow
works too. Both good finds, but unfortunately not helpful for my case.

I'm porting a component to C# and need to be able to drop it onto existing
servers and have existing ASP code work as-is. So I can't change how the
VBScript code is structured. I need my wonderful new C# component to be able
to deal with the array as it's passed in. Doesn't seem unreasonable. Can
anybody tell me how to do that?

Thanks very much,

Christopher Robert

PS: It was bad enough I had to change all of my string params to object
(followed by ToString()) in order to handle incoming strings. Looks like
everyone is having these problems and so it might be time for a good KB
article.



Relevant Pages

  • Re: VBscript Array Split Function
    ... inputted into an array so that each separate character in the array is ... make sense and can't be handled properly by VBScript. ... Dim strValue, strChar, k, arrChars() ...
    (microsoft.public.scripting.vbscript)
  • Re: problems with binary types in an ADO recordset
    ... I'm having problems extracting values from binary types in VBscript. ... You can't directly address individual array elements, ... Dim strTemp ... ' Convert Byte-Array to VBScript ANSI string. ...
    (microsoft.public.scripting.vbscript)
  • Re: problems with binary types in an ADO recordset
    ... VBScript has some support for arrays of bytes, but it is very limited, and doesn't work at all like arrays of variants. ... You can't directly address individual array elements, ... Dim strTemp ... My advice would honestly be to not use binary data in VBScript unless you can treat it as an opaque blob of bytes. ...
    (microsoft.public.scripting.vbscript)
  • Re: Make vbScript An Exe
    ... The problem is I don't know vb at all, and I'm pretty good at vbscript. ... an array for reference ... Call GetGroupInfo ' Fill the array with Group Membership ... Sub GetGroupInfo() ...
    (microsoft.public.vb.general.discussion)