HEELPBOOK - Visual Basic 6 - How to Disable All controls in a form? ############################################ ########### SCENARIO How to disable some control in form? For example, disable all command button and all textbox in a form??? ########### SOLUTION (1st Method) Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is CommandButton Then ctrl.Enabled = False End If Next ########### Function Version (by Heelpbook Staff) Public Function disena(switch As Integer) If switch = 1 Then enable = True Else enable = False End If Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is CommandButton Then ctrl.Enabled = enable End If Next End Function ########### SOLUTION (2nd Method) To disable all of them you can simply disable entire form - until your main logic is done user won't be able to close the form: Private Sub Command1_Click() 'disable form Me.Enabled = False 'do your main stuff here 'reset the form Me.Enabled = True End Sub ############ ARTICLE INFO ############# Article Month: July Article Date: 11/07/2012 Permalink: http://heelpbook.altervista.org/2012/visual-basic-6-how-to-disable-all-controls-in-a-form/ Source: http://www.vbforums.com/showthread.php?t=560128 Language: English View more articles on: http://www.heelpbook.net/ Follow us on Facebook: http://it-it.facebook.com/pages/HeelpBook/100790870008832 Follow us on Twitter: https://twitter.com/#!/HeelpBook Follow us on RSS Feed: http://feeds.feedburner.com/Heelpbook Follow us on Delicious: http://delicious.com/heelpbook