473,405 Members | 2,141 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,405 software developers and data experts.

Initializing structure arrays.

I have defined a structure of;

Private Structure Menu
Private MenuID as string
Private Label as string
End Structure

....and I would like to create and initialize an array of type "Menu". I have
tried numerous variations on the theme;

Public arrMenu as Menu = {{"a","b"},{"c","d"},{"e","f"}}

....but all to no avail. Is this possible? If so how?

Thanks

Steve
Nov 21 '05 #1
2 2987
In article <ua**************@TK2MSFTNGP15.phx.gbl>, Steve wrote:
I have defined a structure of;

Private Structure Menu
Private MenuID as string
Private Label as string
End Structure

...and I would like to create and initialize an array of type "Menu". I have
tried numerous variations on the theme;

Public arrMenu as Menu = {{"a","b"},{"c","d"},{"e","f"}}

...but all to no avail. Is this possible? If so how?

Thanks

Steve


Private Structure Menu
Public Sub New (ByVal MenuID As String, ByVal Label As String)
Me.MenuID = MenuID
Me.Label = Label
End Sub

Public MenuID As String
Public Label As String
End Structure

Public arrMenu () As Menu = _
{New Menu ("a", "b"), New Menu ("c", "d"), New Menu ("e", "f")}

--
Tom Shelton [MVP]
Nov 21 '05 #2
Hi Tom, thanks for your swift response.

I think I see what's happening. The "New" sub within the "Menu" structure
gets called for each invocation of the "new Menu" request, and the code
assigns the variables to it's own structure by use of the "me" keyword.

I knew there had to be a way to do this but I couldn't make the leap of
imagination needed to see that it involved a "constructor" type subroutine
within the structure.

Thanks again

Steve

"Tom Shelton" <to*@YOUKNOWTHEDRILLmtogden.com> wrote in message
news:Od**************@TK2MSFTNGP14.phx.gbl...
In article <ua**************@TK2MSFTNGP15.phx.gbl>, Steve wrote:
I have defined a structure of;

Private Structure Menu
Private MenuID as string
Private Label as string
End Structure

...and I would like to create and initialize an array of type "Menu". I
have
tried numerous variations on the theme;

Public arrMenu as Menu = {{"a","b"},{"c","d"},{"e","f"}}

...but all to no avail. Is this possible? If so how?

Thanks

Steve


Private Structure Menu
Public Sub New (ByVal MenuID As String, ByVal Label As String)
Me.MenuID = MenuID
Me.Label = Label
End Sub

Public MenuID As String
Public Label As String
End Structure

Public arrMenu () As Menu = _
{New Menu ("a", "b"), New Menu ("c", "d"), New Menu ("e", "f")}

--
Tom Shelton [MVP]

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Doug C via .NET 247 | last post by:
Using C#... I am pulling shared memory in to my app that is in the form of apredefined structure. I have arrays in 2 sub-structures. Onearray is an array of another predefined structure, and the...
10
by: Bart Goeman | last post by:
Hi, I have a question about how to put redundant information in data structures, initialized at compile time. This is often necessary for performance reasons and can't be done at run time (data...
4
by: Chuck Ritzke | last post by:
Okay, just when I thought I was starting to understand stuff. In VB6... Type MyDataType Dim Value1 as double Dim Value2 as double End Type Dim MyData1 as MyDataType Dim MyData2 as MyDataType
2
by: James | last post by:
Hi, I need help with a couple of questions, I have create and structure like: Structure byteArray Public byteA() As Byte End Structure Public ptrArray() As byteArray
14
by: Dennis | last post by:
If I have a structure like; Public Structure myStructureDef Public b() as Byte Public t as String End Structure If I pass this structure, will the values in the array b be stored on the...
10
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I...
12
by: Mik0b0 | last post by:
Hallo. Let's say, there is a structure struct struct10{ int a1; int a2; int a3; int a4; }count={ {10,20,30,40}, {50,60,70,80}
5
by: hankypan1 | last post by:
Hi All, I need a tree data structure for my application. It is the non -cyclic simple tree where i can have any number of children node and each child can recursively become a sub tree like a...
2
by: Martin Payne | last post by:
I am trying to initialise a structure with random values for all its fields. It is a large structure so I do not want to do it for each element in turn (it would take ages). Please note my...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.