Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Form OnClosing

Posted on 2006-07-18
9
Medium Priority
?
282 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 64

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

773 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