Link to home
Start Free TrialLog in
Avatar of sata
sata

asked on

Automatically close a program after running

Hi,

I wrote a VB program, and the process goes like this:

On Form_Load
   subRead_the_ini_file
   cmdActivate_click
End sub

Actually after cmdActivate_click I would like the program to just close up, but I realize as I put the click event under the Form_load, although on activate the program it will automatically run the functions under the click event, but after it is comleted, the form will show up in the screen.

I'm planning to put this program in a server and let it automatically run every nite, so nobody will be there to close this program. How can I make it close?

Thanks,
sata
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

try put "End" just after cmdActivate_click ?

like:

...
cmdActivate_click
End
Exit Sub
...
ASKER CERTIFIED SOLUTION
Avatar of rinksno1
rinksno1

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sanjeev_karnik
sanjeev_karnik

After the execution of the code in Activate event call the form unload event and close the application there.
In your cmdActivate_click you jusst need the following line:

Unload Me

And the program will finish and the form won't show up
Add a timer control on form, disable it, set Interval on 500, instead of cmdActivate_click put Timer1.Enabled =True

private sub Timer1_Timer()
  timer1.enabled = false
  unload me
end sub