You are asking for reflection dude!
A for each like thing, you say? well... I don't remember my VB too
well, but I'll make an exception just for you...
in C# it would be like... (this is a didactic help for myself)
foreach (var field in typeof(Employee_Def).getFields())
{
//...
}
How does that translate to VB? I think this is it:
For Each field In GetType(Employee_Def).getFields()
'...
Next
The type if field is FieldInfo, it's under System.Reflection
namespace. I like reflection and emmision a lot, so just ask whatever
you need on this.
You may want to poke around with the members of Type, you can find
methods to read fields by it's name for example.
On 4 mayo, 19:15, MichaelL <[email protected]> wrote:
> Does anyone know how to retrieve the names of the variables/elements
> within a stucture in vb.net?
>
> Given the following structure:
>
> Structure Employee_Def
> Dim EmployeeName as String
> Dim EmployeeNumber as Integer
> End Structure
>
> Dim Emp as Employee_Def
>
> I would like use something like a 'for each' to display the name(not
> the value) of each variable("EmployeeName ", and "EmployeeNumber").
> Any help would be greatly appreciated.