Solved

Dynamically read value of a property from a structure or class.

Posted on 2004-10-07
2
211 Views
Last Modified: 2010-04-23
Ok, I pass in an unknown structure into a function.  I can get the name of the structue, and the name of each property within.  How do I get the values?  

    Public Sub GetStructure(ByRef oStructure As Object)
        Dim tStructure As Type = oStructure.GetType
        Dim sTempFieldName As Reflection.FieldInfo
        Dim oValue As Object

        Try
            Console.Write("Structure Name: " & tStructure.Name)

            'for each item in structure, get it's name and value
            For Each sTempFieldName In tStructure.GetFields
                oValue = ?  'Value of oStructure for current field sTempFieldName
                Console.Write("  Variable Name: " & sTempFieldName.Name & " - Value: " & oValue)
            Next
        Catch ex As Exception

        End Try
    End Sub
0
Comment
Question by:zebrachris
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 12252858
FieldInfo.GetValue?

Bob
0
 

Author Comment

by:zebrachris
ID: 12253037
D'oh - so simple!

Thanks
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question