CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: unload me

  1. #1
    Join Date
    Oct 1999
    Posts
    3

    unload me

    I have a very basic one form program. I am trying to make it exit if a certain condition is true. Right now I am using the following:

    If CountDown > 5 then Unload me



    CountDown is an Integer variable.
    When the statement is true, I keep getting the message, "Run-time error '364': Object was Unloaded"
    Is there any problem with using Unload Me in an IF statement?


  2. #2
    Join Date
    Apr 1999
    Location
    Brooklyn, NY USA
    Posts
    171

    Re: unload me

    You have a problem somewhere else. You can use this simple code to check that the problem with If and Unload me doesn't exist. Place Timer1 on Form, set its Interval = 1000 (1 sec) and paste this code:

    private intCountDown as Integer
    private Sub Timer1_Timer()
    intCountDown = intCountDown + 1
    If intCountDown > 3 then
    Unload me
    End If
    End Sub



    Run your project and you'll see it will be unloaded in 3 seconds without any problem.
    Vlad


  3. #3

    Re: unload me

    If the statement unload me is in your form_load event procedure, move it to the form_activate procedure if you can.

    Charlie Zimmerman
    http://www.freevbcode.com


  4. #4
    Join Date
    Oct 1999
    Posts
    3

    Re: unload me

    I kept it in form_load but got rid of a module that was set to the startup form and set my frmMain to the startup. It worked then.


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

Featured