Text1.Tag = Now Text2.Tag = Now Dim myControl As TextBox For Each myControl In Me.Controls myControl.Text = myControl.Tag Next myControlFor ALL controls: (Use TypeOf to distinguish specific control-type)
Text1.Tag = Now Text2.Tag = Now Dim myControl As Control For Each myControl In Me.Controls If TypeOf myControl Is TextBox Then myControl.Text = myControl.Tag Next myControlThis won't work correctly for VB.NET, though, since they enforce Control-ownership differently: child-controls won't be included in the collection
Public Sub SetFormControlsTooltips(ByRef myControlsCollection As Control, ByVal myTooltip As ToolTip) Dim myControl As Control For Each myControl In myControlsCollection.Controls If TypeOf myControl Is TextBox Then Dim myTextBox As TextBox = DirectCast(myControl, TextBox) If myTextBox.MaxLength > 0 Then myTooltip.SetToolTip(myControl, "Max Length: " & myTextBox.MaxLength & " char(s)") End If If TypeOf myControl Is GroupBox Or TypeOf myControl Is Panel Then Call SetFormControlsTooltips(myControl, myTooltip) End If Next End Subusage: