Results 1 to 17 of 17

Thread: DoEvent

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    DoEvent

    any one now how can i free DoEvent Stack (clear empty ..stop )
    i tray lackwindowsUpdate and me.visible=false its working but not 4 me

    thanks

  2. #2

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    Re: DoEvents

    yes DoEvents

    let say im runing a loop for 1 day lol

    now i click on a button on the Form whan the loop is finsh
    it's run

    it going to do the event mouse down ? that i did before

    or any events that i did ? how can i stop it from doing Events ?

    my project dont have any DoEvents()

    thanks
    Last edited by imosha; Dec 3rd, 2005 at 10:17 PM.

  4. #4
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: DoEvent


  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    Re: DoEvent

    Example
    Private WorkInProgress as boolean

    Private sub Command1_Click()
    WorkInProgress =true
    dim X as long
    for x=1 to 10000
    debug.print time
    next
    WorkInProgress =false
    ''''((( free eventes )))
    end sub

    Private sub Command2_Click()
    if WorkInProgress =true the exit sub ' not working
    debug.print "Click Whan the loop is runing"
    '''''((( i dont like that command 2 will work )))
    end sub
    Last edited by imosha; Dec 3rd, 2005 at 10:43 PM.

  6. #6
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: DoEvent

    I think I understand what you're looking for. You don't want the user to be able to click any buttons while your program is in the middle of doing work.

    There is no quick option that I'm aware of.

    But it's not very difficult to handle it in code.

    Before you start your loop, set a variable like WorkInProgress=True

    Then in your click event just do

    If WorkInProgress Then Exit Sub

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: DoEvent

    You can set the enabled property of the buttons to False while your code is running.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    Re: DoEvent

    WorkInProgress not working

    and Enabeld not working



    the only way that it will work is if i put DoEvents in the loop
    Last edited by imosha; Dec 3rd, 2005 at 10:48 PM.

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: DoEvent

    You don't need it to fire every iteration on the loop, unless each iteration takes very long. You could have it fire every 10 to 1000 iterations.
    VB Code:
    1. for x=1 to 10000
    2.   if x mod 1000 = 0 then doevents
    3. endif

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    Re: DoEvent

    The Events are stack in windows i like 2 delete them after the loop is
    finsh how can i find them i dont know and how 2 delete them
    and only them?

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    Re: DoEvent

    Quote Originally Posted by dglienna
    You don't need it to fire every iteration on the loop, unless each iteration takes very long. You could have it fire every 10 to 1000 iterations.
    VB Code:
    1. for x=1 to 10000
    2.   if x mod 1000 = 0 then doevents
    3. endif
    yes i now it will work but not on my program
    i dont have a small loop but if i must i do that
    i like 2 free the events all events

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: DoEvent

    I don't understand what you are trying to do. You are running a loop, and you don't want users to click on a button? If you set command1.enabled=false, they won't be able to press the button. If you use DoEvents, it WILL allow them to press the button while your loop is executing.

    Please explain exactly what you want to happen.

  13. #13
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: DoEvent

    use lockwindow update to lock your window so it cant be touched.

  14. #14
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: DoEvent

    VB Code:
    1. Private Sub Command1_Click()
    2.     MsgBox "This app will now run in the background"
    3.     Form1.Visible = False
    4.     Do Until x > 1000
    5.    
    6.     Loop
    7.     Form1.Visible = True
    8. End Sub

  15. #15
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: DoEvent

    Quote Originally Posted by Jmacp
    VB Code:
    1. Private Sub Command1_Click()
    2.     MsgBox "This app will now run in the background"
    3.     Form1.Visible = False
    4.     Do Until x > 1000
    5.    
    6.     Loop
    7.     Form1.Visible = True
    8. End Sub
    The Form1.Enabled should do better. This way the user will be able to see the form but can't do anything on it.

    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  16. #16
    Hyperactive Member umilmi81's Avatar
    Join Date
    Sep 2005
    Location
    Sterling Heights, Mi.
    Posts
    335

    Re: DoEvent

    Quote Originally Posted by Pradeep1210
    The Form1.Enabled should do better. This way the user will be able to see the form but can't do anything on it.

    Pradeep
    Good answer. Yes, set form1.enabled = false and then form1.enabled = true when you are done with your loop.

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Posts
    106

    Re: DoEvent

    it's not the best

    what u need 2 do if this what u like is 2 put a contener Like a picbox and set him 2 false and not the form.

    but what i was asking is that i like 2 free the event stack in windows

    that it will do the last event only

    but i think i must stay whit that
    thank you all 4 helping me
    you are the best



    this is the code


    pic.enabeld= false
    for I= 1 to 10000
    if I mod 200 = 0 then doevents (or down)
    debug.print Time

    next I
    (or up) doevents
    pic.enabeld=true
    end sub

    sorry abut my english i cant read or right well
    http://msdn.microsoft.com/library/de...dowshookex.asp
    this is a defrant way 2 do that didnt test it yet
    Last edited by imosha; Dec 4th, 2005 at 07:42 PM.

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