Can this be done?

  • Thread starter Thread starter Tony Van
  • Start date Start date
T

Tony Van

Is there any way to construct a line of code in a VB.net
program from a string?

Something like this...
Dim sStr As String = "txtName"

Dim sField As String = "name"

Dim cCmd As String

cCmd = sStr & ".DataBindings.Add('Text', myADO.ds, 'snat.'"
& sField & ")"

..... and make cCmd a line of code that looks like:

txtName.DataBindings.Add("Text", myADO.ds, "snat.name")

Hope this is not too dumb a newbie question. Thanks.
 
No, there isn't a way to do this. Well....There isn't a <i>nice</i> way to
do this and it does introduce a <i>huge</i> performance penalty. Also, there
is just about never a reason to do this. If you do think you need to do
this, your first step should be to rethink how you want to achieve your
results. You'll find that there is always an alternate method that works
better.

For instance...In your case, adding all of your TextBox's to your own
collection or array would achieve the same results without having to worry
about their names.
 
Back
Top