You could use a dictionary. First, store your values from your config file into a dictionary, and then copy them to your local variables, if you so desire.

// get info from config file

Dim dTmp As New Dictionary

For... loop through your config file

  dTmp.Value(<key>) = <value>

Next

// copy info to variables

weight = dTmp.Lookup("weight", <defaultvalue>)
maxSpeed = dTmp.Lookup("maxSpeed", <defaultvalue>)

// done.

HTH
Andrew Keller

On Oct 3, 2006, at 12:23 PM, Kevin Windham wrote:

Is there a smart way to access an object and it's properties from a string.

Suppose I have an object of class Car and properties of weight and maxSpeed. If I read in a config file that has some config parameters for this car,

weight: 5000
maxSpeed: 248

along with a whole bunch of other parameters, is there a decent way to set up my code to fill those parameters in without using a bunch of case of if statements?

i.e.

case paramstring = "weight"
        weight = paramstringvalue

etc. for pages and pages.

Thanks,
Kevin

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to