473,385 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Defining Structure within Structures

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
3 5157
* "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
>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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Richard Harris | last post by:
Hello, Consider this: struct MBD { double x; double y; int i; }
3
by: Muhammad Farooq-i-Azam | last post by:
Hi, I am trying to define an arp structure but having problem doing so. I think I have define the correct arp structure but I find myself in a strange problem. The size of structure that I have...
5
by: Joe Thompson | last post by:
Hi I am new to C# and am rewritting some C++ code. I want to send a byte array over a serial port. The elements of the byte array are really a structure I have populated. My question is, how do...
5
by: mblatch | last post by:
Another basic C# question, but haven't figured out how to do this one either. Am used to defining a list of structures in C++, but am unsure if you can do this in C#. As a simplified example, I...
2
by: ksarkar | last post by:
I have a problem regarding array of structures within a structure. I have an static array of structure within a structure eg. typedef struct { int x; }A; typedef struct { int...
28
by: kyle york | last post by:
Greetings, Why does the C standard require the members of a structure not be re-ordered (6.2.5.20)? Padding is allowed, and platform dependent, which means one cannot rely on the exact layout...
3
by: Amit_Basnak | last post by:
Dear Friends I have the follwoing function "tss_fe_get_own_info" which has the arguments as shows below tss_fe_get_own_info(char *user_id, tss_user_profile_t **p_buf_UserSecInfo, error_status_t...
4
by: eBob.com | last post by:
In my class which contains the code for my worker thread I have ... Public MustInherit Class Base_Miner #Region " Delegates for accessing main UI form " Delegate Sub DelegAddProgressBar(ByVal...
25
by: jbholman | last post by:
I am pretty new to C and doing my first project in C. I actually read almost the entire FAQ, but can't seem to figure out this problem. I have a structure. I have a list of these structures. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.