I have trouble marshalling array
I have a VB COM class myclass
Imports System.Runtime.Remoting
Imports System.Runtime.InteropServices
<ComClass(myClass.ClassId, myClass.InterfaceId, myClass.EventsId)> _
Public Class myClass
Public Function atst(ByVal iCnt As Integer, _
<MarshalAs(UnmanagedType.LPArray, ArraySubType:=UnmanagedType.LPStr,
SizeParamIndex:=1)> ByRef astr As String(), _
<MarshalAs(UnmanagedType.LPArray, SizeParamIndex:=1)> ByRef iPosn()
As Integer) _
As Integer
Dim lstrI() As Integer = {1, 2, 3, 4, 5}
Dim iarr() As Integer
Dim lstrA() As String = {"a", "b", "c", "d", "e"}
iarr = lstrA.Clone()
If iCnt >= 5 Then
iCnt = 5
astr = lstrA.Clone()
Return iCnt
ElseIf iCnt > 0 Then
ReDim Preserve lstrA(iCnt)
astr = lstrA.Clone()
Return iCnt
Else
iCnt = 0
End If
Return iCnt
End Function
When I call from vbscript
set myClass = createObject("myClass.myClass")
iSz = myClass.atst (iCnt, str_results , iarr)
' gives "Microsoft VBScript runtime error: Variable uses an Automation
type not supported in vbscript: 'atst'"
what did I do wrong?
Should I have a differnt call prototype for VBSCRIPT versus C style
application?