VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



I had several forms with several controls on each. I wanted to clear each control, but I wanted to

by Elliot McCardle (3 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 6th May 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

I had several forms with several controls on each. I wanted to clear each control, but I wanted to make it as painless as possible. This code

Rate I had several forms with several controls on each. I wanted to clear each control, but I wanted to




    Dim sMask As String

    For Each Control In frm.Controls
        If TypeOf Control Is TextBox Or TypeOf Control Is ComboBox Then
            Control.Text = "" 'Clear text
        End If
        If TypeOf Control Is MaskEdBox Then
            With Control
                sMask = .Mask 'Save the existing mask
                .Mask = "" 'Clear mask
                .Text = "" 'Clear text
                .Mask = sMask 'Reset mask
            End With
        End If
        If TypeOf Control Is DTPicker Then
            Control.Date = Date 'Set to current date
        End If
    Next Control

End Sub

Download this snippet    Add to My Saved Code

I had several forms with several controls on each. I wanted to clear each control, but I wanted to Comments

No comments have been posted about I had several forms with several controls on each. I wanted to clear each control, but I wanted to . Why not be the first to post a comment about I had several forms with several controls on each. I wanted to clear each control, but I wanted to .

Post your comment

Subject:
Message:
0/1000 characters