How to pass vbscript array variable to shared object using ByRef 
Author Message
 How to pass vbscript array variable to shared object using ByRef

I'm having problems accessing an array that is passed in to a shared
routine which is defined in an .exe It seems I can not figure out the
syntax to pass in the array, change it from within my shared function,
then have the script access the new array elements.

Here's my script snippet:

Dim MyArray(16)
shChange MyArray  

Here's my shChange function declaration:

Sub shChange(ByRef MyArray() As Variant)
'change MyArray elements
End Sub

Even when I do not get a syntax error, I do not get the expected
values from my array.

What am I doing wrong?  How can I avoid syntax errors AND access the
new array elements from the vb script?

Thanks for you help.

Mark



Sun, 01 Feb 2004 23:05:49 GMT  
 How to pass vbscript array variable to shared object using ByRef

Quote:
> I'm having problems accessing an array that is passed in to a shared
> routine which is defined in an .exe It seems I can not figure out the
> syntax to pass in the array, change it from within my shared function,
> then have the script access the new array elements.
> Sub shChange(ByRef MyArray() As Variant)
> 'change MyArray elements
> End Sub

How about

Sub shChange(ByRef MyArray As Variant)

Best regards
Johnny Nielsen



Mon, 02 Feb 2004 06:42:17 GMT  
 How to pass vbscript array variable to shared object using ByRef

Quote:

> How about

> Sub shChange(ByRef MyArray As Variant)

> Best regards
> Johnny Nielsen

Yes!  That's the ticket Johnny.  Thank you.  I thought I had tried
every syntactical possibility but that one must have slipped through
the cracks.  I'm not out of the woods yet though :(

My next step is to use the Split functio such as:  MyArray =
Split(MyString, MY_DELIMITER) from within my shared object.
Unfortunately, VB does not like that.  As a result, I get a Runtime
Error 485 with msg "Variable uses an automation type not supported in
Visual Basic".  So now this is what has me stumped.  I have a
workaround, obviously I can parse the string myself and stuff the
array, but I guess this error is more out of curiosity then anything
else.

Again, thanks for taking the time to reply and providing a solution to
my original problem.

Regards,
HawgRyder



Mon, 02 Feb 2004 20:47:05 GMT  
 How to pass vbscript array variable to shared object using ByRef
Hawg,

I'm not 100% about this but I think the problem is that VB doesn't like to
use arrays with a predefined size with Split(). Try something like:

Sub Main
    Dim MyArray()
    shChange MyArray, "this;that;the other"
    MsgBox "Number of elements: " & UBound(MyArray)
End Sub

Sub shChange(MyArray, MyString)
    MyArray = Split(MyString, ";")
End Sub

This is all done from (fairly bad) memory so you may need to tidy it up a
bit.

HTH,

Tony.


Quote:

> > How about

> > Sub shChange(ByRef MyArray As Variant)

> > Best regards
> > Johnny Nielsen

> Yes!  That's the ticket Johnny.  Thank you.  I thought I had tried
> every syntactical possibility but that one must have slipped through
> the cracks.  I'm not out of the woods yet though :(

> My next step is to use the Split functio such as:  MyArray =
> Split(MyString, MY_DELIMITER) from within my shared object.
> Unfortunately, VB does not like that.  As a result, I get a Runtime
> Error 485 with msg "Variable uses an automation type not supported in
> Visual Basic".  So now this is what has me stumped.  I have a
> workaround, obviously I can parse the string myself and stuff the
> array, but I guess this error is more out of curiosity then anything
> else.

> Again, thanks for taking the time to reply and providing a solution to
> my original problem.

> Regards,
> HawgRyder



Wed, 04 Feb 2004 00:31:02 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. passing javascript variable into asp variable using vbscript

2. pass array to dll ByRef

3. ByRef or not ByRef, that is the array?

4. Can't access Array via shared object and VBScript

5. ByRef Variable Passing from ASP to COM

6. passing a byref array

7. Passing arrays byref

8. How to pass control array ByRef?

9. Passing a control array byRef ??

10. pass array to dll ByRef

11. pass array to dll ByRef

12. passing a control array byref

 

 
Powered by phpBB® Forum Software