devxlogo

Disabling All Controls on a Form

If you ever need to disable all the controls on a form you can loopthrough the control array and set each Enabled property to Falsewith this code:

 Sub cmdArray_Click () Dim iLoop As Integer For iLoop = 0 To Me.Controls.Count - 1 Me.Controls(iLoop).Enabled = False Next iLoop End Sub 

An alternatively is to set the Enabled property of the form toFalse, which effectively disables the entire form:

 Me.Enabled = False 

There is a side effect to the second method, however: because youcan’t use the control menu from the form, there is no way to close theform. You’ll need to have another form unload this disabled form.

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Seven Service Boundary Mistakes That Create Technical Debt

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.