|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can this be done?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. -- <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. > > > 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. > >
same sub, multiple control click events
same sub, multiple control click events OpenFileDialog how to search a datatable-can I use sql on a vb2005 datatable? Results differ between Windows App and Console App. Why??? best starting point for complete newbies? Navigate through a dataset Default MessageBox Title Delegates: String or Integer Reference to a control error. Toolstrip |
|||||||||||||||||||||||