how to pass the array from vb to vbscript 
Author Message
 how to pass the array from vb to vbscript

hi world,

can you tell me how to pass the array from vb to VBScript?
i use statement like: sc.run "procedure_name",array_param.
and how to receive that array from vbscript and how to
manipulate that array in vbscript.

tq fro your attention.



Fri, 01 Oct 2004 17:42:03 GMT  
 how to pass the array from vb to vbscript

Quote:

>can you tell me how to pass the array from vb to vbscript?
>i use statement like: sc.run "procedure_name",array_param.
>and how to receive that array from vbscript and how to
>manipulate that array in vbscript.

(Having problems with my newsserver, this may be a double
posting)

PRB: Script Error Occurs When Referencing Non-variant
Array (Q165967)
http://support.microsoft.com/default.aspx?scid=kb;EN-
US;q165967

HOWTO: Return Arrays from Server-Side Objects in ASP
(Q174576)
http://support.microsoft.com/default.aspx?scid=kb;EN-
US;q174576

HOWTO: Implement Array Arguments in Visual Basic COM
Objects for Active Server
Pages (Q217114)
http://support.microsoft.com/default.aspx?scid=kb;EN-
US;q217114

From a previous newsgroup thread:

<qoute>

Subject: Re: Passing Arrays from VBScript to COM Object
Newsgroups: microsoft.public.scripting.vbscript
Date: 2000/01/10

Your COM object's method needs to accept a variant
argument containing an array of variants.   To return an
array, do the same thing in reverse - build an array of
variants and return it in a variant.  In the script you
simply pass the array as an argument as an ordinary
variable and return an array from a function into an
ordinary variable.

'A VB component method with a variant array
'passed in a variant argument...
'
Public Sub testMethod(ByRef theArray As Variant)
    ...
    ...use IsArray(theArray) to sanity check...
    ...
End Sub

'A VB component function returning a variant array
'as a variant return value...
'
Public Function testFunction(ByRef someArgument As
Variant) As Variant
Dim myArray(9) As Variant
    ...
    ...load myArray
    ...blah, blah...
    ...
    testFunction = myArray
End Sub

In the script client...

Dim FooArray(3)
...
...load FooArray
...
myObject.testMethod FooArray
...
whatever = "whatever"
BarArray = myObject.testFunction(whatever)
a = BarArray(0)
b = BarArray(1)
...

--
Michael Harris
</qoute>

--
torgeir



Fri, 01 Oct 2004 22:42:29 GMT  
 how to pass the array from vb to vbscript

Quote:
> can you tell me how to pass the array from vb to vbscript?
> i use statement like: sc.run "procedure_name",array_param.
> and how to receive that array from vbscript and how to
> manipulate that array in vbscript.

A WSH hosted example below.  For a VB/VBA host, just make sure you pass variant arrays, not stongly typed arrays of native types.

for example...

Dim array_param(3) As Variant

*not*

Dim array_param(3) As String

==================================================================

set sc = createobject("msscriptcontrol.scriptcontrol")
Set c = CreateObject("Scripting.Dictionary")

c(c.count) = "sub mysub(arParams)"
c(c.count) = "  dim sParams"
c(c.count) = "  sParams = join(arParams,vbcrlf)"
c(c.count) = "  msgbox sParams"
c(c.count) = "end sub"

sc.language = "vbscript"

sc.addcode join(c.items,vbcrlf)

arArgs = Array("abc",1,2,"xyz")

sc.run "mysub",arArgs

msgbox "done..."

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Fri, 01 Oct 2004 22:50:58 GMT  
 how to pass the array from vb to vbscript

Quote:

> hi world,

> can you tell me how to pass the array from vb to vbscript?
> i use statement like: sc.run "procedure_name",array_param.
> and how to receive that array from vbscript and how to
> manipulate that array in vbscript.

PRB: Script Error Occurs When Referencing Non-variant Array (Q165967)
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q165967

HOWTO: Return Arrays from Server-Side Objects in ASP (Q174576)
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q174576

HOWTO: Implement Array Arguments in Visual Basic COM Objects for Active Server
Pages (Q217114)
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q217114

From a previous newsgroup thread:

<qoute>

Subject: Re: Passing Arrays from VBScript to COM Object
Newsgroups: microsoft.public.scripting.vbscript
Date: 2000/01/10

Your COM object's method needs to accept a variant argument containing an array
of variants.   To return an array, do the same thing in reverse - build an array
of variants and return it in a variant.  In the script you simply pass the array
as an argument as an ordinary variable and return an array from a function into
an ordinary variable.

'A VB component method with a variant array
'passed in a variant argument...
'
Public Sub testMethod(ByRef theArray As Variant)
    ...
    ...use IsArray(theArray) to sanity check...
    ...
End Sub

'A VB component function returning a variant array
'as a variant return value...
'
Public Function testFunction(ByRef someArgument As Variant) As Variant
Dim myArray(9) As Variant
    ...
    ...load myArray
    ...blah, blah...
    ...
    testFunction = myArray
End Sub

In the script client...

Dim FooArray(3)
...
...load FooArray
...
myObject.testMethod FooArray
...
whatever = "whatever"
BarArray = myObject.testFunction(whatever)
a = BarArray(0)
b = BarArray(1)
...

--
Michael Harris
</qoute>

--
torgeir



Fri, 01 Oct 2004 18:00:57 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Can anyone tell about multiple transactions

2. Graphical mode under Win95

3. Cache update w/Text or Memo field

4. Passing Arrays into VbScript from a VB dll

5. Passing arrays from VBScript to VB DLL

6. Passing Arrays to a VB 5.0 SP3 DLL using VBScript control

7. Passing arrays from a VB dll into a VBScript

8. Passing array from VB to DLL and returning array

9. Passing an array (or array of a structure) from VB to VC++

10. Passing arrays from ASP To VB-components...need help

11. passing arrays to vb dll

12. HELP! Run time error 200

 

 
Powered by phpBB® Forum Software