Defining Structure within Structures

O

Obrecht

Hi.

I am new to VB .NET and am just starting to do some
testing with it. I am trying to define a fixed length
array of structures within a structure. I pass this
structure to a Win32 Btrieve API.

I have one main structure and within that I need to have a
fixed length array of 200 other structures. Below -
shortened versions of the structures.

Thanks,
Jen


<StructLayout(LayoutKind.Sequential, Pack:=1,
CharSet:=CharSet.Ansi)> _
Structure udtBtrGroups
Dim intNumber1 As Short
Dim intNumber2 As Short
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=1,
CharSet:=CharSet.Ansi)> _
Structure udtBtrRecord
Dim intNumber3 As Short
Dim intNumber4 As Short
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=200)> _
Dim udtGroup() As udtBtrGroups
End Structure
 
H

Herfried K. Wagner [MVP]

* "Obrecht said:
I am new to VB .NET and am just starting to do some
testing with it. I am trying to define a fixed length
array of structures within a structure. I pass this
structure to a Win32 Btrieve API.

I have one main structure and within that I need to have a
fixed length array of 200 other structures. Below -
shortened versions of the structures.

Do you have the C++ declarations for the structures and functions?
 
O

Obrecht

Do you have the C++ declarations for the structures and
functions?
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
.

Yes, below are the C++ equivalents. I did get more
information back from Microsoft that marshalled nested
structure arrays are not supported by framework 1.x. We
are currently looking at another solution using a buffer
and pointer.

Thanks,
Jen

typedef struct
{
short number1;
short number2;
}GROUPS;
typedef struct
{
short number3;
short number4:
GROUPS group[200];
}BTR_REC, *BTR_REC_PTR;

Get Record Function:
long DLLENTRY BtrGetRecord(long file_type, long read_mode,
long lock, void *item, char *pos_blk, char key_num)
 
C

Craig Vick [MSFT]

Hi Jen,

I think all you need to change is the last line of udtBtrRecord to

Dim udtGroup(199) As udtBtrGroups.

Craig
VB.Net Team
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top