I have a button on this tabpage which, when a user clicks, clears all of the fields. However, I have set one textbox to a read-only textbox which has a counter in it. How can I programmatically clear all of the other fields, minus this textbox. (There are other textboxes on this tab.

This is what code I have for clearing the textbox fields:

  For Each Me.cControl In TabPage3.Controls
            If (TypeOf cControl Is TextBox) Then
                cControl.Text = ""
            End If

Test the Name property you gave to this control in an if, and don't clear it.

How about

For Each tbx As TextBox In Me.Controls.OfType(Of TextBox)()
    If Not tbx.ReadOnly Then
        tbx.Text = ""
    End If
Next

Works for me Rev. Thanks!

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.