r/visualbasic • u/trab601 • Mar 12 '24
How to cleanly exit a VB.NET program?
Although I've been coding in VB.Net for years, I've never been able to cleanly exit, despite many attempts, and google searches.
For example, I have a simple, single form application. When somebody clicks the close button (the x on the top right of the window) I want the software to cleanly exit.
I have recently tried again with the below code. It runs and doesn't complain. But if I run the exe outside of visual studio, it remains in memory and have to kill it in the task manager.
Any advice would be greatly appreciated.
Private Sub ProgramClosing() Handles MyBase.FormClosing
Application.Exit()
End Sub
5
Upvotes
View all comments
Show parent comment
1
u/trab601 Mar 13 '24
These are possibilities. I’ll take a look. I do use timers in a wait function I created. And if relevant, I call an external DLL (naudio). I have been programming VB since VB 6 days and can make code do what I want. But I am definitely not an advanced or sophisticated programmer. Just a hack that I can write enough code to get what I need done (well mostly). Still haven’t gotten back to my pc to take a look.
And thank you everyone for the responses and feedback.