I'm using verion 3.5 of the .NET framework

I have a form with a number of controls including text boxes.

All my text boxes are named in the style txb_name, can I search for controls with txb in their name? The following code doesn't work:

For Each tb As TextBox In Me.Controls.Find("txb", True)
'do something with tb
next

I tried using OfType but that gives the error: 'OfType is not a member of System.Windows.Forms.Control.ControlCollection'

any ideas?

TIA

Hx

P.S. I wanted to discuss this in relation to a similar post, but apparently that isn't allowed on this forum.

I've sorted it out:

For Each c As Control In Me.MyPanel.Controls
    If c.Name.StartsWith("txb_") Then
         
'use textboxes here

Next

Maybe not the most elegant solution, but it works!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.