Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reference sever control textbox via stringbuilder 1

Status
Not open for further replies.

hamking01

Programmer
May 30, 2004
238
US
I have about 30 text boxes of 3 different types all named using the same convention. Is there a way to reference these textbox's with a stringbuilder.

for example with the following list of textbox Id's:

txtABCdate
txtBCDdate
txtCDEdate

I need to get the text value of each text box. Looking for something like

Dim Names As String() = {"ABC", "BCD", "CDE"}
For each key in Name
'get the text for textbox (txtABCdate.text)
 
What about placing the server controls into an array?

Could something below be possible:

(txtABCdate.text, txtABCname.text, txtABCaddress.text)

For each key in "above array"
'get text and perform some action

This way I could create a number of different arrays (one for each person) and perform some action like inserting into db.

 
You could create a TextBox array to hold each textbox. e.g.
Code:
Private MyTextBoxes() As TextBox

    Public Sub New()
        ReDim MyTextBoxes(30)
        MyTextBoxes(0) = txtABCdate
        MyTextBoxes(1) = txtBCDdate
        etc ...
    End Sub
Then you can just loop through each item. e.g.
Code:
    For Each tmpTextBox As TextBox In MyTextBoxes
    ' Do stuff with tmpTextBox.Text
    Next

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
Did this work?

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
ca8msm,

Thank you, it does work. Found that i can't use it though. need to have it work as described in the other thread, which by the way you're also replying to. Thank you for help. Really appreaciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top