Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I really dont know how to name this topic :)

Status
Not open for further replies.

advers

Programmer
Oct 15, 2005
2
BA
I have a listbox in which user picks an option, and depending on that choice I want to access different fields of some object and perform some manipulation. For example, if user picks an option “Title”, I want my program to perform operations with movie.Title

The only way I had in mind to handle this would be to make one big switch statement in which I would check user’s choice and perform all of the operations according to that choice. In this case, I would have to write almost same code(only difference is which field I use for manipulation) quite a few times, and I’d like to avoid duplicating that quantity of code :)

Is there some other, more elegant way to do this? I guess using pointers to appropriate fields and assigning them after user selects something would do the job… Is there some other way I can create some kind of “alias” for a field?

I guess all of this sounds very messy, but I hope you got the point.

tnx in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top