Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Structure to COM object

Status
Not open for further replies.

FRoeCassNet

Programmer
Feb 8, 2002
147
US
I recently upgraded from VB6 to VB.NET and I'm having trouble figuring out how to pass a structure to a COM object.

In VB6 I used:
-- Structure --
Private Type ParamInfo
sVal As String * 40
lVal As Long
End Type
Private Type ParamInfoStr
Buffer As String * 42
End Type
-- Property --
Private Property Get ParamData() As Variant
Dim b() As Byte
Dim p1 As ParamInfo
Dim p2 As ParamInfoStr

p1.sVal = "Test"
p1.lVal = -1
LSet p2 = p1
b = p2.Buffer
ParamData = b
End Property

This would return the full structure as an 84 byte array.

How do I do this in VB.NET? I've tried playing with structures, unions, etc. but can't seem to figure out how to convert my structure into a byte array that contains all the data.

Thanks in advance for any help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top