Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: VB7
Expertise: Intermediate
May 26, 2003



Application Security Testing: An Integral Part of DevOps

ResetControls - Reset the value for the input array of controls

' Resets the value for the input array of controls, and thier child controls
' Example:
'   - reset all the controls on the form: ResetControls(Me)
'   - reset specific controls: ResetControls(TextBox1, CheckBox1, GroupBox1)

Sub ResetControls(ByVal ParamArray ctls() As Control)
    ' clear input control
    Dim ctl As Control
    For Each ctl In ctls
        If TypeOf (ctl) Is TextBoxBase Then
            CType(ctl, TextBoxBase).Text = ""
        ElseIf TypeOf (ctl) Is CheckBox Then
            CType(ctl, CheckBox).Checked = False
        ElseIf TypeOf (ctl) Is RadioButton Then
            CType(ctl, RadioButton).Checked = False
        ElseIf TypeOf (ctl) Is ListView Then
            CType(ctl, ListView).Items.Clear()
        ElseIf TypeOf (ctl) Is TreeView Then
            CType(ctl, TreeView).Nodes.Clear()
        ElseIf TypeOf (ctl) Is ListBox Then
            CType(ctl, ListBox).Items.Clear()
        ElseIf TypeOf (ctl) Is ComboBox Then
            CType(ctl, ComboBox).Items.Clear()
            CType(ctl, ComboBox).Text = ""
            ' Note: to add support for more controls just add more ElseIf blocks
        End If
        ' clear all child controls, if any
        Dim c As Control
        For Each c In ctl.Controls
End Sub
Marco Bellinaso
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date