[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 147
  • Last Modified:

vb application

I have a vb app, when I x out of the program, it still shows up in my task manager.

How do I prevent this?
0
jackjohnson44
Asked:
jackjohnson44
  • 3
  • 3
  • 2
  • +1
2 Solutions
 
TimCotteeCommented:
Hi jackjohnson44,

Make sure you have completely closed all running forms etc.

In your main form's unload event include something like:

Dim frmToClose As Form
For Each frmToClose In Forms
    If Not (frmToClose Is Me) Then
        Unload frmToClose
    End If
Next

This will explicitly unload all forms in the application when you close the main one.

Tim Cottee
0
 
jackjohnson44Author Commented:
thanks, do I have to worry about open com ports or database connections?
0
 
TimCotteeCommented:
jackjohnson44,

As a general rule, you should *always* manage the lifecycle of every object you create. So if you instantiate an object, open a connection or a form then you should ensure that you close it cleanly when you have finished using it. If you have com connections then you should ensure that you close the port when the form that the control sits on is closed. Likewise a database connection should be closed and set to nothing when you have finished with it.

Tim
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
lunchbyteCommented:
Any open hidden forms will keep it in the task bar or the task manager. If you forget to close your com or database connection then that will not keep the name in the task bar or the task manager but the computer resources is a different story.

If you are using MDI environment then set MDIForm.auotshowchildren to true and you will see which form comes up when it should not. Sometime I call the from name by mistake so this allow me to track that down.

Use timcottee code in your MDI Form or your main from unload event. That will make sure everything is unloaded.
0
 
burningmaceCommented:
On the form that you close:

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    ' Insert code to close any COM ports and db connections.
    End
End Sub

That will do what you want.
0
 
jackjohnson44Author Commented:
is there a way to loop through db connections like TimCottee did with forms?
0
 
lunchbyteCommented:
Are you saying that db connection is the one keeping the application name in the task bar or task lists? If so then that does not make sense.


Did you use global variable for your database connection?
0
 
jackjohnson44Author Commented:
no, the form answer that TimCottee gave seems to work, and it wasn't the task bar, it was the task manager applications list.

Someone said I should close my db connections, I was wondering if there was a similar thing that I could do.

I think that it is working correctly now, but wanted to add that functionality if it would help.

Thanks
0
 
lunchbyteCommented:
You cannot loop through any open db connection especially if you used local variable. When that procedure is done, any local variable used in that procedure cannot be accessed again.

If you use the global variable for db connection then just make sure it is close and do something like this set db = nothing. If it is local variable then you will have to make sure you remember to do that for each procedure. Remember, it’s a good habit but in theory when you close out of the program or even exit out of the procedure, VB6 will close it and reclaim the resources. I have seen that it is not true sometime.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now