how do i refer to objects like text boxes as if they were in an array. basically i want to be able to say
(TextBox + i).Text = "..."
basically, how can i refer to a textbox where i have a variable of type string as the name of the textbox?
thanks
Printable View
how do i refer to objects like text boxes as if they were in an array. basically i want to be able to say
(TextBox + i).Text = "..."
basically, how can i refer to a textbox where i have a variable of type string as the name of the textbox?
thanks
If you mean like control arrays as in VB6 , then this's already died out .
here's one way ...
VB Code:
[color=blue]Dim[/color] tb [color=blue]As[/color] Control [color=blue]For Each[/color] tb [color=blue]In MyBase[/color].Controls [color=blue]If[/color] tb.Name = "TextBox1" [color=blue]Then[/color] tb.Text = "some text" [color=blue]End If[/color] [color=blue]Next[/color]
If he really means controls array , then it isn't this one ;)Quote:
Originally posted by dynamic_sysop
here's one way ...
VB Code:
[color=blue]Dim[/color] tb [color=blue]As[/color] Control [color=blue]For Each[/color] tb [color=blue]In MyBase[/color].Controls [color=blue]If[/color] tb.Name = "TextBox1" [color=blue]Then[/color] tb.Text = "some text" [color=blue]End If[/color] [color=blue]Next[/color]