473,804 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

2 Message Boxes Displayed when User Clicks Button

The following is the onclick method called when the "Renew" button is
clicked by the user in my Windows application:

Expand|Select|Wrap|Line Numbers
  1. .....
  2.  
  3. Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
  4. eventArgs As System.EventArgs) Handles cmdRenew.Click
  5.  
  6. Try
  7. If x Is Nothing Then
  8. Exit Sub
  9. End If
  10. If y > 0 Then
  11. If z = 0 Then
  12. MsgBox("Random Message")
  13. Exit Sub
  14. End If
  15. Else
  16. Exit Sub
  17. End If
  18. If a Then
  19. MessageBox.Show("Random Message")
  20. Exit Sub
  21. End If
  22. If (b Or c) Then
  23. MsgBox("Random Message")
  24. Exit Sub
  25. Else
  26. If d Then
  27. ...
  28. If e Then
  29. MsgBox("Random Message")
  30. Exit Sub
  31. End If
  32. Else
  33. If f Then
  34. ...
  35. If g Then
  36. MsgBox("Random Message")
  37. Exit Sub
  38. End If
  39. Else
  40. MsgBox("Random Message")
  41. Exit Sub
  42. End If
  43. End If
  44. End If
  45.  
  46. ''Problem Here
  47.  
  48. If (h = 123) Then
  49. MsgBox("This Message Displays to the User while Done!
  50. MessageBox is also being Displayed")
  51. Exit Sub
  52. End If
  53. If i <> "" Then
  54. ...
  55. If j Then
  56. MsgBox("Random Message")
  57. Exit Sub
  58. End If
  59. If k Then
  60. ...
  61. Else
  62. If l Then
  63. ...
  64. Else
  65. ...
  66. End If
  67. End If
  68.  
  69. ''Gets to here
  70. h = 123
  71. DoEvents()
  72. MessageBox.Show("Done!", "", MessageBoxButtons.OK)
  73. Else
  74. MsgBox("Random Message")
  75. End If
  76. Catch ex As Exception
  77. ErrorTrap(ex,
  78. System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
  79. End Try
  80. End Sub
  81.  
  82.  
At first I didn't have the DoEvents() call before the Done! MessageBox
was displayed, but the Done! box would be displayed in the background
of the form and the user couldn't get to it withou ALT+TAB-ing to it. I
attempted to fix that and found that adding the DoEvents() call before
the Message Box was displayed fixed it, but now sometimes when the user
clicks the button, the Done! messagebox is displayed then the
MsgBox("This Message Displays to the User while Done! MessageBox is
also being Displayed") is displayed and locks up the whole program,
both that MEssage Box and the Done! message box are reached using the
ALT+TAB and the program freezes up. It seems as thought it runs through
the whole onclick, sets h = 123, displays the Done! message box, then
loops the onclick method again and gets to the h=123 check and sees it
now as true and displays that message box too.

Any thoughts, if it is the DoEvents() call that is causing it then does
anyone have a solution as to why the Done! message box is only
reachable using ALT+TAB by the user without the DoEvents() call?

Nov 21 '05 #1
2 2943
jburkle wrote:
The following is the onclick method called when the "Renew" button is
clicked by the user in my Windows application:

[code].....

Private Sub cmdRenew_Click( ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArg s) Handles cmdRenew.Click

<snip>
''Problem Here

If (h = 123) Then
MsgBox("This Message Displays to the User while Done!
MessageBox is also being Displayed")
Exit Sub
End If
<snip>
''Gets to here
h = 123
DoEvents()
MessageBox.Show ("Done!", "", MessageBoxButto ns.OK)
Else
MsgBox("Random Message")
End If


It seems like your event handler is being called twice. Can you put
MessageBox.Show ("Button Clicked!") at the top of the click event to
confirm this?

If it gets called twice, do you use the AddHandler statement anywhere?

Nov 21 '05 #2
It does seem like the handler is being called twice. Is it a possiblity
that a double-click on the button could cause it to be called twice, or
could the Application.DoE vents() cause it?

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
983
by: Galina | last post by:
Hello I have an asp page, which is designed to allow selection from 5 interdependant select boxes. User selects and submits. A database is queried with selected values as parameters and another page based on the query results is displayed. All works fine. When User clicks the button "Back" in browser to return to the first form, only the 1st check box has the same value. The 2nd one has the first item in the list instead of what was...
8
2588
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and courses are populated. When course is selected, lists of occurrences, groups and
3
6265
by: Kay | last post by:
Hello, I have two list boxes on my form, one initially displays blank, and through javascript it is possible to move items from one box to another, this works fine, I followed an article titled "How to move items between Lists with Javascript" http://www.devx.com/GetHelpOn/10MinuteSolution/16372. My problem is that I also have a dropdown list on the page with autopost back = true, and a procedure to handle the text changed event of the...
2
1357
by: vvenk | last post by:
Hello: I have a weblayout that uses frames. It has three frames, one on the top that displayes the header (header.aspx), one on the left that displays the system menu (menu.aspx) and one on the right that different application forms are displayed in. I have an Login button on my login screen that is displayed in the right frame. When the user clicks on this Login button, it validates the user id and password. If the validation is...
0
269
by: jburkle | last post by:
The following is the onclick method called when the "Renew" button is clicked by the user in my Windows application: ..... Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdRenew.Click Try If x Is Nothing Then
12
1938
by: jburkle | last post by:
Hello all, I am still having an issue where multiple Message Boxes are being displayed to the user from the same form at one time. This issue hides the boxes behind the forms since the forms take up the whole desktop most of the time when maximumized and also the boxes are only reachable when ALT is used. Once the multiple OK buttons are clicked the application freezes up and needs to be restarted. I have posted this before and the...
7
16369
by: PW | last post by:
Hi, I have a form with unbound fields on it. The user selects a record from a recordset and I populate the unbound fields. When I try to change the unbound quantity text box, Access 2003 tells me "The data has been changed. Another user edited this record and saved the changes before you attempted to save your changes. Re-edit the record." This does not always happen. And yes, I can re-edit the quantity text
8
13109
by: g_man | last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of a command button that closes the form. I have code in the Form_Error event that does a good job of providing a more meaningful error message than the default. It works in every situation except when the user clicks the close button. I am using Me.Dirty=False to force a save but if there are duplicates I just get the standard Runtime 3022 error message. I am wondering...
0
1804
jgroos
by: jgroos | last post by:
Here is my scenario: I have two different reports processed LOCALLY, lets say Report1.rdlc and Report2.rdlc. They both are populated with data from a database, and they both also take a list of parameters. Each report has a button the user clicks to view them, AND, they both WORK. HOWEVER, when the user clicks the button a second time, the table on the report is displayed AGAIN, right below table from the last load. I'm talking the WHOLE...
0
9704
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9571
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10561
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.