Home All Groups Group Topic Archive Search About
Author
27 Jun 2006 9:15 PM
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.

Author
28 Jun 2006 1:39 AM
Dave Kreskowiak
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.

--
<i><b>RageInTheMachine9532</b></i><font size="-2">
"<i>...a pungent, ghastly, stinky piece of cheese!</i>" <b>-- The Roaming
Gnome</b></font>


Show quoteHide quote
"Tony Van" wrote:

> 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.
>
>
>
Author
28 Jun 2006 2:14 AM
Tony Van
Thanks Dave for pointing me in the right direction. I forgot
about collections.




Show quoteHide quote
"Tony Van" <ton-jud-***@comcast.net> wrote in message
news:YN2dnVOSbqCJPTzZnZ2dnUVZ_tednZ2d@comcast.com...
> 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.
>
>