PDA

Click to See Complete Forum and Search --> : Need to know how to external functions byRef


kondal
Jan 9th, 2001, 06:41 PM
Friends
I need to know in a VBScript how to do I call a method with 2 parameters by reference.
I tried call

Object = CreateObject(ActiveX.function)
and then
Object.method (ByRef array1, ByRef array2) and it did not work.

I need to pass this by reference only because the method will update the array information based on some validation.

Would appreciate any help

Thanks

Clunietp
Jan 9th, 2001, 11:25 PM
In your ActiveX object, make sure your parameters are defined as byref myArray as variant

Example:

Public Function DoIt(ByRef MyArray1 as Variant, ByRef MyArray2 as Variant) as Boolean




Tom

kondal
Jan 10th, 2001, 09:45 AM
In my called methood, I already have it as
methodA (ByRef arr1 As Variant, ByRef arr2 As Variant)
but still whatever I pass is still taking by value.
In fact, I wrote a small VB stub which calls this method and I am noticing that the array is called by Reference. It is only when I am calling in VBscript that it is calling the method by Value, on default.
Thanks
Kondal

Clunietp
Jan 10th, 2001, 10:16 PM
Hey Kondal

I just sent this to you in an Email, but if you don't get it, here it is

This works fine for me: my VB function is able to modify the contents of the array and ASP is then able to read the changes

ASP code

<%@Language=VBScript EnableSessionState=False%>
<% option explicit

dim myArray1(0)
dim myArray2(0)

dim objObject

set objObject = server.CreateObject("prjTest.Class1")

call objObject.doit(myArray1, myArray2)

set objObject = nothing

Response.Write myArray1(0)
Response.Write myArray2(0)

%>


VB Code -- call your project "prjTest" and leave the default class name as "Class1"

Public Sub DoIt(ByRef myArray1 As Variant, ByRef myArray2 As Variant)

myArray1(0) = "HelloWorld!"
myArray2(0) = "Hi!"

End Sub