I have 44 text boxes on a screen (to be precise, RadNumericTextBoxes but that’s not germane). They follow a common naming pattern (rntb_[NameOfDBField]) which can’t be programmatically replicated.
How can I set .Value to Nothing for each control which has a name ^= rntb_? I have attempted the following:
Private Sub ClearValues()
For Each c as Control in Controls
If TypeOf c Is RadNumericTextBox Then
TryCast(c, RadNumericTextBox).Value = Nothing
End If
Next
End Sub
However, Controls.Count = 1 and contains just the name of the master page.
Do I need to pass an argument to Controls, or do I need to do something else altogether? It’s “only” 44 text boxes so I could clear each one manually but I’d rather do it programmatically if possible.
If the RadNumericTextBoxes are on the Form and not in a container, then something along the lines of
But if they are in, say, GroupBox1 then you would replace
Me.Controlsin the above withGroupBox1.Controls.And what is the
End Forin your code? A For..Next loop hasNextat the end of its body in VB.NET.