473,326 Members | 2,732 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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 2916
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.EventArgs) 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!", "", MessageBoxButtons.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.DoEvents() cause it?

Nov 21 '05 #3

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

Similar topics

0
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...
8
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...
3
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...
2
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...
0
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...
12
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...
7
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...
8
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...
0
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.