Showing posts with label mystruct. Show all posts
Showing posts with label mystruct. Show all posts

Thursday, March 22, 2012

Structure

Hello,

I have created a structure, MyStruct, with 3 properties: Name
(String), Valid (Boolean) and Type (Enumeration Type).

I need to do the following:
1. Create a list of items of type MyStruct using a simple method like:
MyStruct.Add(...)
2. Access each list item using a For Loop.

Could someone, please help me out?

I have been trying collections, arrays, adding methods inside my
structure but I have not been able to make this work.

Thank You Very Much,
MiguelIf you are using 2.0, a generic list is the best approach.

dim something as new List(of MyStruct)

something.Add(firstStructure)

for each struct as MyStruct in something
'do something
next

Karl

In 1.x, you can either use an ArrayList, or create a custom collection by
extending the CollectionBase class

--
http://www.openmymind.net/
http://www.fuelindustries.com/
"shapper" <mdmoura@.gmail.comwrote in message
news:1173113846.509770.105130@.q40g2000cwq.googlegr oups.com...

Quote:

Originally Posted by

Hello,
>
I have created a structure, MyStruct, with 3 properties: Name
(String), Valid (Boolean) and Type (Enumeration Type).
>
I need to do the following:
1. Create a list of items of type MyStruct using a simple method like:
MyStruct.Add(...)
2. Access each list item using a For Loop.
>
Could someone, please help me out?
>
I have been trying collections, arrays, adding methods inside my
structure but I have not been able to make this work.
>
Thank You Very Much,
Miguel
>

Structure

Hello,

I have created a structure, MyStruct, with 3 properties: Name (String), Valid (Boolean) and Type (Enumeration Type).

I need to do the following:
1. Create a list of items of type MyStruct using a simple method like:
MyStruct.Add(...)
2. Access each list item using a For Loop.

Could someone, please help me out?

I have been trying collections, arrays, adding methods inside my structure but I have not been able to make this work.

Thank You Very Much,
Miguel

shapper:

Hello,

I have created a structure, MyStruct, with 3 properties: Name (String), Valid (Boolean) and Type (Enumeration Type).

I need to do the following:
1. Create a list of items of type MyStruct using a simple method like:
MyStruct.Add(...)

Rather Use Classes where you can have the above 3 properties & also get Methods Like Add() ,Delete() etc.Then Create an Array of that Class.
2. Access each list item using a For Loop.
When u make the Array of a Class u can use the For/ForEach loops to access the element of the array.
Could someone, please help me out?

I have been trying collections, arrays, adding methods inside my structure but I have not been able to make this work.

Thank You Very Much,
Miguel