Solved

Form OnClosing

Posted on 2006-07-18
9
267 Views
Last Modified: 2008-02-01
Hi guys, little question here.

I got some code on this Sub:

Private Sub frmRoom_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

It refers to another Private Sub to do a MsgBox ... for testing...
I NEVER receive the msgbox, it looks like the form close before or it dont like me or something...
So I cant know if my other code ligns after my MsgBox is good or wrong...

Any solution ? not to be able to see if my other ligns are ok, but really WHY it doesnt show up the msgbox

thanks, 500 pts on that
0
Comment
Question by:PhilippeRenaud
  • 4
  • 4
9 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 17134109
Hi PhilippeRenaud;

If you are exiting you application with an Application.Exit() statement the Form.Closing method is not called. You can click on the X in the Title bar and that will fire the Closing method. You can also use the Me.Close() method which will close the form and if that is the main form will exit the application and fire the Closing method of the form.

Fernando
0
 
LVL 34

Expert Comment

by:Sancler
ID: 17137353
This, with its reference to "Handles Me.FormClosing", looks like VB.NET 2005 rather than VB.NET 2002 or 2003: those would refer to "Handles MyBase.Closing".  And, so far as I know (and I've just done a little test to check), the difference that Fernando mentions between .Close and Application.Exit is not perpetuated in 2005.  So it looks to me as though something else might be going on that what you've said so far doesn't reveal.  Can you please post the actual code from both this sub and the private sub which it calls?

Roger
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 17137606
Yes, I'm using VB 2005

Well okai.. :

    Private Sub frmRoom_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Send("uf " + CStr(tableID))
        mobjClient.Close() ' to fix
    End Sub

Note that Send is doing some Socket/thread works okai, it will go in this Private Sub even if I dont call it (thats work 100%) :

Private Sub DisplayText(ByVal t As String)
  Select Case t.Substring(0, 1)
     Case "u"
         MsgBox("Testing Closing")
  End Select
End Sub
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 17137636
I just test something... its qite strange , let me tell you :

The msgBox doesnt work... but I did try to change data on my sql database and it works....
So its like that on Closing it does not accept Prompt command or something .. ?
0
 
LVL 34

Expert Comment

by:Sancler
ID: 17137791
But, on that code, the Sub DisplayText is not called by frmRoom_FormClosing.  So the reason why it is not called (or the call is failing) must lie in - I assume - the Send() Sub.

Roger
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 17137808
No I know it is not call in the Closing, but the Send Sub refers to some other codes that will refer to DisplayText.
Like I said, It did work for changing some data in my SQL but my damn MsgBox will never prompt .. ..
0
 
LVL 34

Accepted Solution

by:
Sancler earned 500 total points
ID: 17137955
The problem (or at least the only problem) is not in the Closing.  When A calls B and B calls C (... and C calls D, etc) you are not going to sort out why the last in the chain of calls does not happen unless you trace things from A to B to C etc.  It is clear, from what you say, that A (frmRoom_FormClosing in this case) is successfully firing and calling B (Send, in this case).  But that tells us nothing at all why the last in the chain (DisplayText in this case) is either not firing, or it is firing but not producing the results you expect.  We (or at least I) cannot just guess what the other links are in the chain, or what might be going wrong in implementing them.  In order to try help we (or at least I) would need to see those links in code.  If you don't want to post the code that implements those links, all I can suggest is that you put a breakpoint on the line

        Send("uf " + CStr(tableID))

in frmRoom_FormClosing and single-step through the code thereafter to see whether the Sub DisplayText is in fact called and, if it is, what value is assigned to its t argument.

Roger
0
 
LVL 1

Author Comment

by:PhilippeRenaud
ID: 17137995
I understand what you are sayign Sancler, thank you
I just cant post all that code here..

I will try to figure out why it doesn work having in mind those A B C calls

Thanks for the help, I appreciate
0
 
LVL 34

Expert Comment

by:Sancler
ID: 17138030
OK

Come back if you can get close to, but not precisely identify, what is going wrong and feel you can post just the part/s of the code that are relevant to this specific issue.  I'll be happy to try to handle that in this thread, even though it's now been closed.

Thanks for the points

Roger
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML - Color not displaying correctly in EMAIL. 6 49
VB.Net WebRequest Code from JSON curl 7 50
vb.net 1 month apart 11 35
VB.net Open video relating to control 2 19
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question