Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleIgnore events during a long process by disabling the form
Keywordsignore events, events, disable
CategoriesTips and Tricks, Controls
 
Disable the form(s) whose events you want to ignore.

This example sets the form's Enabled property to False and then starts a 5 second countdown. All events are ignored until the count finishes and the program sets Enabled to True.

 
Private Sub Command1_Click()
    Enabled = False ' Disable the form.
    Screen.MousePointer = vbHourglass
    Label1.Caption = "5"
    m_Count = 5
    DoEvents

    Timer1.Enabled = True
End Sub

' Count down from 5.
Private Sub Timer1_Timer()
    m_Count = m_Count - 1
    Label1.Caption = Format$(m_Count)

    If m_Count = 0 Then
        Timer1.Enabled = False
        Enabled = True  ' Enable the form
        Screen.MousePointer = Default
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated