|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to change the name of multiple textboxesI have a lot of textboxes in a form, i numberd them from from 1 til 10. for example: txtZpr1.text txtZpr2.text etc.. I want to fill these textboxes by using a loop. Is there a way to fill them by changing the number of the textbox?? TIA Jan --------------= Posted using GrabIt =---------------- ------= Binary Usenet downloading made easy =--------- -= Get GrabIt for free from http://www.shemes.com/ =- On Nov 21, 11:21 am, "Jan" <> wrote:
> Hi there, for I as integer = 0 to 10> > I have a lot of textboxes in a form, i numberd them from from 1 til 10. > > for example: txtZpr1.text > txtZpr2.text etc.. > > I want to fill these textboxes by using a loop. > > Is there a way to fill them by changing the number of the textbox?? > > TIA Jan > dim txt as TextBox = CType(Me.Controls("txtZpr" & I.ToString()), TextBox) txt.Text = "New Text" Next
Show quote
Hide quote
On Nov 21, 10:21 pm, "Jan" <baggerd***@hotmail.com> wrote: You can use reflection to get all the controls of the form, of your> Hi there, > > I have a lot of textboxes in a form, i numberd them from from 1 til 10. > > for example: txtZpr1.text > txtZpr2.text etc.. > > I want to fill these textboxes by using a loop. > > Is there a way to fill them by changing the number of the textbox?? > > TIA Jan > > --------------= Posted using GrabIt =---------------- > ------= Binary Usenet downloading made easy =--------- > -= Get GrabIt for free fromhttp://www.shemes.com/ =- interest, and then set any property / invoke any member on those controls. Google this for the syntax, which is easy enough to be understood. Thanks, coolCoder -------------------------------------------------------------------------------------------------------------------------------------------------- If you find this post helpful, please rate it. Jan wrote:
> I have a lot of textboxes in a form, i numberd them from from 1 til 10. Yes, there is.> for example: txtZpr1.text, txtZpr2.text etc.. > > I want to fill these textboxes by using a loop. > > Is there a way to fill them by changing the number of the textbox?? But don't. Visual Basic may not have VB's Control Arrays but, instead, you can have Arrays of Controls: Dim allmyTextBoxes As TextBox() _ = {txtZpr1, txtZpr2, ... txtZpr10} For Each tb as TextBox in allmyTextBoxes tb.Text = tb.Name Next HTH, Phill W. exact,
Just to show that it is as well my favorite which I learned from an answer from Armin by the way, :-) Cor |
|||||||||||||||||||||||