Solved

Form OnClosing

Posted on 2006-07-18
9
262 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 62

Expert Comment

by:Fernando Soto
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:PhilippeRenaud
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 34

Expert Comment

by:Sancler
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now