HighTechTalks DotNet Forums  

How to pass Collection object from VBScript to .NET

Dotnet VSA microsoft.public.dotnet.vsa


Discuss How to pass Collection object from VBScript to .NET in the Dotnet VSA forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
SMMI
 
Posts: n/a

Default How to pass Collection object from VBScript to .NET - 07-06-2005 , 03:12 AM






Good Day

Overview

I need to call a .NET object's functions within VBScript and pass a VBScript
collection into this function call.

My VBScript receives a Collection object consisting of Recordsets. I want to
pass this Collection object from VBScript to my .NET object's function. Below
are the relevant code fragments from VBScript and .NET. I’ve added all
necessary references.

--------------------------------------------------------
VBScript
--------------------------------------------------------
Function Process(Inputs as Collection) as ADODB.Recordset

Dim a
Set a = CreateObject("Test.TestObj")

Set Process = a.funcReturnRS(Inputs)

End Function

--------------------------------------------------------
..NET
--------------------------------------------------------
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
Imports ADODB
Imports VBA

Namespace Test
<Guid("D6F88E95-8A27-4ae6-B6DE-0542A0FC7039"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)> _
Public Interface ITestObj
<DispId(5)> Function funcReturnRS(ByVal inp As VBA.Collection) As
ADODB.Recordset
End Interface

<ProgId("Test.TestObj"), _
ClassInterface(ClassInterfaceType.None), _
Guid("13FE32AD-4BF8-495f-AB4D-6C61BD463EA4")> _
Public Class TestObj
Implements ITestObj

Public Function funcReturnRS(ByVal inp As VBA.Collection) As ADODB.Recordset
Implements ITestObj.funcReturnRS

Return inp
End Function

The Problem

The code above doesn’t behave as expected. I can pass a single recordset
(with e.g. Inputs.Item(2)) from VBScript, but I cannot pass a whole
Collection object to .NET.

I receive the error “Invalid procedure call or argument: a.funcReturnRS”
when I try to. Is there any way to do this? I’ve already tried adding the
Collection contents to an ArrayList and Dictionary object with the same
results. Using an Array is out of the question because Inputs are dynamic
data.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.