I have 100 textbox in my form. Their names are tb1, tb2, ... tb100
I need to retrieve the values from these 100 textboxes.
How can I use a loop to address these 100 textboxes name?
Zod Saturday, September 02, 2006 1:04 PM
Try this: Dim values(99) As String For ix As Integer = 1 To 100 Dim txt As TextBox = Me.Controls("tb" + CStr(ix)) If txt IsNot Nothing Then values(ix-1) = txt.Text Next
nobugz Saturday, September 02, 2006 2:31 PM
for each currentControl as Control in Me.Controls
if TypeOf(currentControl) Is TextBox then
Dim theTextBox as TextBox = currentControl
'do your stuff with theTextBox as it has now been made the same textbox as the textbox on the control
end if
next
ahmedilyas Saturday, September 02, 2006 1:37 PM
Try this: Dim values(99) As String For ix As Integer = 1 To 100 Dim txt As TextBox = Me.Controls("tb" + CStr(ix)) If txt IsNot Nothing Then values(ix-1) = txt.Text Next