|
|
| Author |
Message |
victorf
Joined: 01 Jan 2006
Posts: 342
Location: Schenectady, New York
|
|
Posted: 01 November 2006, 14:13 PM Post subject: counting elements in a structure |
|
|
Is there any way to find out how many data items are in a structure:
Structure MyStruct
Public a as byte
Public b as byte
Public c as byte
End Structure
This structure contains 3 data items. Can I determine that programatically?
Any enlightenment will be appreciated.
Vic |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 01 November 2006, 15:54 PM Post subject: Re: counting elements in a structure |
|
|
| victorf wrote: | | Is there any way to find out how many data items are in a structure? |
Only if you know the sizes of the elements. In the example that you gave all of the elements are Byte. Consequently, SizeOf(MyStruct) \ SizeOf(Byte) is a compile-time constant that gives the number of elements.
If the structure contains elements having different sizes, the problem becomes more difficult. |
|
| Back to top |
|
 |
|