Solved

Form OnClosing

Posted on 2006-07-18
9
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

635 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