Results 1 to 5 of 5

Thread: How to have a command button to cancel a long process?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 1999
    Location
    dubai
    Posts
    39

    Post

    Hello!


    I am using vb5. I want to have a command button to cancel a long process. If I place a timer control and look for the command button click, it never happens.

    When the process starts, the screen freezes and only a listview is updated. But the buttons doesn't get focus. How do I do it?


    Thanks,




    ------------------
    ganraj.

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Put a DoEvents statement in the loop.

    ------------------
    Marty

  3. #3
    Guest

    Post

    Scatter a few "DoEvents" statements in your code to give Windows a chance to do other things while your program is running...if your process if a loop then just put "DoEvents" in once inside the loop. This will give the user chance to click the Cancel button.

    Now make a public variable eg "Dim bCancel As Boolean" and when the Cancel button is pressed set this vairble to true.

    Then make your process regularly check the contents of this variable and about if it becomes true. I personally would make this check after each "DoEvents" statement.

    ------------------
    Matthew Ralston
    E-Mail: [email protected]
    ICQ:31422892
    Web Sites:The Blue Link My Home Page (Not up at the moment!)

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 1999
    Location
    dubai
    Posts
    39

    Post

    Hello Marty!


    Thanks... It works...




    ------------------
    ganraj.

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 1999
    Location
    dubai
    Posts
    39

    Post

    Hello Mathew!


    Thanks to you also...




    ------------------
    ganraj.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width