By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,481 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,481 IT Pros & Developers. It's quick & easy.

Defining Structure within Structures

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
* "Obrecht" <jl*****@hotmail.com> scripsit:
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?

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #2

P: n/a
>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)
Nov 20 '05 #3

P: n/a
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
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).

--------------------
Content-Class: urn:content-classes:message
From: "Obrecht" <jl*****@hotmail.com>
Sender: "Obrecht" <jl*****@hotmail.com>
Subject: Defining Structure within Structures
Date: Mon, 27 Oct 2003 08:32:38 -0800
Lines: 30
Message-ID: <0a****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOcp+8t1Zj3MdwdS8uCnPAerx/nlA==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.languages.vb
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:150901
NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

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

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.