Results 1 to 6 of 6

Thread: halting code

  1. #1
    Guest
    Hey all....


    How can I stop code from executing when a from is show? Like in a commondialog and a msgbox?


    Code:
    Private Sub Form_Load()
    
    frm2.Visible = True
    
    
    'other code here...
    How could I do it so that code stops executing after frm2 is shown, and continue after its hidden/unloaded?

    Sunny

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Exclamation cheating?

    Why not put it another way round:

    Sub Form2_Unload()

    'code here
    form1.show 'load first form again
    End sub

    Alternatively, if you didn't wan't this occuring when the form2 closes, what about delaying the code with a timer control?

    Hope this helps
    Alex

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Fanatic Member
    Join Date
    Mar 2000
    Location
    That posh bit of England known as Buckinghamshire
    Posts
    658
    Alternativley you could show the Form as modal. This will stop code execution in the calling form, until the new form has been unloaded.

    Code:
    frm2.Show vbModal
    Iain, thats with an i by the way!

  4. #4
    Guest
    Alex,

    How would this stop the code from continuing to execute?

    After frm2 is show, the code will continue to execute, and will frm2_unload will only execute when it is unloaded, which by then, countless errors would have occurred because it has already gone through most of the program without the needed variables which are obtained from frm2.


    Sunny

  5. #5
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Talking

    ok good point, this works if it's a 1-2 code line, will give future answers more thought!

    Alex

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  6. #6
    Guest
    This code will show form2 and stop any code below the Loop.

    Code:
    Private Sub Form_Load()
    frm2.Visible = True
    Do
    DoEvents
    Loop
    'other code here...
    End Sub

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