Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I think I'm missing something. I normally end a program with the word "End", which normally works fine.

 

I'm making a program that I need to run a few procedures on FormLoad (actually they're in form activation, cuz they don't work in form load), then after all that, end the program by itself.

 

I tried putting End into the FormLoad event, but that didn't work right, I tried putting it right after all the other subs that needed to be done during activation and the program went a little nutty.

 

Would making a timer and having it 'end' the program after a few ticks work?

 

Is "End" even the proper way to be doing this? the way I'm getting buck nutty results, I"m not so sure

 

Thanks for any advice

  • *Experts*
Posted

You shouldnt use End, ever, its not recommended as it doesnt clean up anything, it only shuts down the program.

If you form doesnt even get shown then what about not having the form at all and using Sub Main to execute the code and then it will exit automatically when the code in Main is done.

Posted

Sometimes its nice to use a form app so you can display status if something goes wrong, or you need input if something happens.

 

Both of these work I think. I'm not sure which one is preferred:

 

me.close

me.dispose

Posted

I have to look into that. A formless program is definately what I want. I'm just not sure how to set that up. Its not a type of project, right?

 

I found Application.Exit() to exit, but ran into a problem. It just cuts off the program wherever I put it.

 

It would get one character out of my first SendKeys string, then terminate. I added Application.DoEvents after all of the SendKeys, then after each individually and it let 4 characters get through before shutting down.

 

I think a formless program would be better.

 

I'm thinking that I add a module, make it a Shared Sub Main, might need to import the form class for some methods, and theres an option somewhere to choose what the startup Form is, and you can probobly select Sub Main, then just delete the form?

 

I'll look into this later and try it out.

  • *Experts*
Posted

You dont need any special type of a project to make app without a form. Simply delete the form, go to your Solution Explorer, right click your project and go to properties and you should see an option called Startup Object. Set it to Sub Main.

You dont need to call Application.Exit() if you dont run any form because when the code in Sub Main finishes it automatically exits.

Posted

Sorry to rehash this and bring it back up again, but if me.close and me.dispose are the preferred and professional way to exit an application and cleanup, what about a formless application.

 

I don't have a me. I tried application.close. I tried:

 

dim x as form = new form

x.close

 

but the program freaked and threw an exception.

 

Right now I'm still using application.exit() to close on error.

  • *Experts*
Posted
If you dont have any forms its logical that you wont use the Close method of the form that the message loop is relaying on :), You can use Application.Exit()

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...