how to allow control to a form when VB code is running

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kalichakradhar
    New Member
    • Mar 2007
    • 8

    how to allow control to a form when VB code is running

    hi
    I have written a program to search in the Excel Sheet but when the Search is in progress neither i am able to minimize the form nor click on other buttons that i have provided to stop the search in the middle. please help me as to how can i achieve this

    Thanks
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Originally posted by kalichakradhar
    hi
    I have written a program to search in the Excel Sheet but when the Search is in progress neither i am able to minimize the form nor click on other buttons that i have provided to stop the search in the middle. please help me as to how can i achieve this

    Thanks
    Hey there, kalichakradhar!

    Do you eventually get the data you need?

    Dököll

    Comment

    • godofredo
      New Member
      • Mar 2007
      • 8

      #3
      Setting the public property KeyPreview = True returns the control to the form.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by kalichakradhar
        hi
        I have written a program to search in the Excel Sheet but when the Search is in progress neither i am able to minimize the form nor click on other buttons that i have provided to stop the search in the middle. please help me as to how can i achieve this
        I believe there are two possible scenarios here:
        1. If your code is issuing a search command to Excel, then is stuck waiting until control returns, I think there's little you can do.
        2. If your code is doing the work itself while you sit and wait, then try putting some DoEvents statements in there. It doesn't matter where, as long as they are executed fairly frequently while your code searches. DoEvents (in pre .Net versions of VB, and I think in VBA) allows Windows to catch its breath and take care of other things like interacting with the user.

        Comment

        Working...