TSFLLC
asked on
How to update textbox value using global string variable as textbox name
I would normally use the following line of code to update the value of a date textbox in a form.......
SpecificForm.DateTextBox.T ext = Format(MonthCalendar1.Sele ctionStart , "MM/dd/yyyy").ToString
BUT, in this particular sub routine I need to be able to update various maskedtextboxes as shown above using a global variable that has the name of the textbox stored in it. Using a select case I'm able to identify the form that contains the date field, but I need to be able to use the global variable in updating the textbox because there are multiple date fields on various forms....as opposed to one date field.
How can I replace "DateTextBox" with the global variable to accomplish the task?
SpecificForm.DateTextBox.T
BUT, in this particular sub routine I need to be able to update various maskedtextboxes as shown above using a global variable that has the name of the textbox stored in it. Using a select case I'm able to identify the form that contains the date field, but I need to be able to use the global variable in updating the textbox because there are multiple date fields on various forms....as opposed to one date field.
How can I replace "DateTextBox" with the global variable to accomplish the task?
ASKER
I see FindForm in the list but I do not see FindControl.
I'm using VB2005 and Framework 2.0.
I'm using VB2005 and Framework 2.0.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I already had a similar function set up on most if not all of my forms when it came to a textbox.....only with this one I needed to add new functions on about ten forms for MaskedTextBox 's.
And after doing that, the procedure worked like a charm.
Thanks! for the effort.
And after doing that, the procedure worked like a charm.
Thanks! for the effort.
dim tbname as string = "mytextbox"
Dim tb As TextBox = CType(Me.FindControl(tbnam
tb.Text = "mytext"