Variable substitution in object name?

  • Thread starter Thread starter Brian Newman
  • Start date Start date
B

Brian Newman

I have a form with five rows of text boxes, displaying data. For
certain reasons, I can't bind these directly to data records, so I'm
using code to load the data into an object, then manually get each
field value and assign it to each text box.

The text boxes are named like this:
txtSPctTrees1 txtSPctShrubs1 txt(etc)1 ...
txtSPctTrees2 txtSPctShrubs2 txt(etc)2 ...
txtSPctTrees3 ...
....

In other languages, I could assign the name of the text box object to
a string variable:
nRowNum = 3
cStr = "txtSPctTrees" & nRowNum.ToString.Trim

Then I could use a variable substitution character in-line to make the
assignment, something like this:
&cStr.Value = oDataRow("Field1")

Can I do anything like that in VB.NET, constructing the name of the
object to reference at runtime from variables?
 
Brian Newman said:
I have a form with five rows of text boxes, displaying data. For
certain reasons, I can't bind these directly to data records, so I'm
using code to load the data into an object, then manually get each
field value and assign it to each text box.

Please avoid multiposts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top