Solved

Form OnClosing

Posted on 2006-07-18
9
269 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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