I have a netexpress program calling a vb subroutine passing 3 integer parameters which works fine.
If I try to pass the second 2 integers as a group then I cannot get it to work. (the group will eventually have about 50 items in it)
VB Prog
Imports System.Runtime.InteropServices
<ComClass(vbpan32.ClassId, vbpan32.InterfaceId, vbpan32.EventsId)> _
Public Class vbpan32
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "253aac3c-266c-4786-a71c-7185051536c2"
Public Const InterfaceId As String = "1882ce84-9369-4d02-ada6-1a6438e56a08"
Public Const EventsId As String = "d610f949-b193-4e5a-9398-7a9ed1426c4b"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
<StructLayout(LayoutKind.Sequential)> Structure wingad_params
<MarshalAs(UnmanagedType.I4)> Public num1 As Integer
<MarshalAs(UnmanagedType.I4)> Public num2 As Integer
End Structure
' Tried without MarshalAs and tried "R8" not "I4", "I8" tried too. SHOULD NOT need this anyway for integers.
'<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=30)> Public Param1 As String
'<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=30)> Public Param2 As String
'<VBFixedString(30)> Public Param1 As String
'<VBFixedString(30)> Public Param2 As String
Public Sub WinGad1(ByVal Func As Integer, ByRef num1 As Integer, ByRef num2 As Integer)
MsgBox("wingad Integer updated")
'
MsgBox("Win Gadget [" & Func & "] " & num1.ToString & " " & num2.ToString)
End Sub
Public Sub WinGad2(ByVal Func As Integer, ByRef Func2 As wingad_params)
MsgBox("wingad Structure")
'
MsgBox("Win Gadget [" & Func & "] " & Func2.num1.ToString & " " & Func2.num2.ToString)
End Sub
End Class
COBOL PROGRAM
$set ooctrl(+p)
* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
identification division.
program-id. winpanvb.
*
environment division.
configuration section.
source-computer. IBM-PC.
object-computer. IBM-PC.
special-names.
call-convention 74 is CallConvension74
console is crt.
* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
class-control.
winpan is class "$OLE$vbpan32.vbpan32".
data division.
* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
working-storage section.
copy "system.d01".
copy "winpan32.d01".
*
01 DLL-Obj object reference.
01 w-params.
03 w-num1 pic 9(8) comp.
03 w-num2 pic 9(8) comp.
01 w-func pic 9(8) comp value 1234.
* -----------------------------------------------------------------
01 w-message.
03 w-mess1 pic x(10) value "winpanvb".
03 w-messcnt pic 9999 value 0.
* ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ
procedure division.
winpan32-main section.
add 1 to w-messcnt.
display w-message.
*
invoke winpan "new" returning DLL-Obj.
move 888 to w-num1.
move 777 to w-num2.
*-------------------------------------------------------
stop "Call DLL-Obj using integers".
invoke DLL-Obj "WinGad1" using w-func
w-num1
w-num2.
*---------------------------------------------------------
stop "Call DLL-Obj using structure".
invoke DLL-Obj "WinGad2" using w-func
w-params.
*---------------------------------------------------------
stop "Call DLL-Obj Test Complete".
winpan32-end.
stop Run.
RESULTS
Calling 1st Routine wingad1 works fine passing integers.
Calling 2nd routine wingad2 with integer and group field fails. Tried to define a sequential structure to equate tto group field (found this in a sample program on MF site) but I must be missing something.