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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to substitute a string for an object field name?

Status
Not open for further replies.

Theseekers

Technical User
Jul 22, 2004
118
0
0
US
Hi Tekers,

I really don't know how to put phase this question but here I go.

I have a data class that allow me to load a record in it so I can manipulate fields that I want. I need to put these fields into a loop so that I don't have to address them individually but I really don't know how to do this. Can some one offer me a suggestion on this.

Here is an example of what I would like to accomplish.

Currently I get to each field in the record by:
mydatarow.item("Field#")

so either to set or assign value I would do:
Code:
  mytextbox1.text = mydatarow.item("Field1").ToString
As you can see, I have or will have some 50 or 60 fields to do this and just want to find out a better ways to loop through them, but I am stucked

How can I substitute the field object name between the ( ) so that I can substitute the # using index of a loop.

My altimate goal is to get something like this


for lcv = 1 to 50
mytextbox(lcv).text = mydatarow.item("Field(lcv)".ToString
next

Thank a million in advance.

P.S. I know how to get to mytextbox by using findcontrol method but don't know how to do smilar thing to the mydatarow.item object.
 
Wouldn't you just do something like:
Code:
mydatarow.item("Field" & lcv).ToString


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top