473,396 Members | 2,037 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,396 software developers and data experts.

Message Box Issue

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 general response is
"MessageBox.Show() stops all code from being called until the user
clicks OK" - while in this situation, something happens that allows the
code to be looped through again while the OK Message Box is displayed
on screen BEFORE the OK is clicked which then shows a second Message
Box from the same form.

See for yourselves:
http://img456.imageshack.us/img456/3747/untitled3dx.png
This small example application has displayed 2 Message Boxes, if this
were a larger sized program then the second box which needs to be
clicked OK first would be behind the whole program and only reachable
through ALT TAB or clicking on it in the taskbar. How is this
possible?!?!

Nov 21 '05 #1
12 1909
jburkle,

Code?

Kerry Moorman
"jburkle" wrote:
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 general response is
"MessageBox.Show() stops all code from being called until the user
clicks OK" - while in this situation, something happens that allows the
code to be looped through again while the OK Message Box is displayed
on screen BEFORE the OK is clicked which then shows a second Message
Box from the same form.

See for yourselves:
http://img456.imageshack.us/img456/3747/untitled3dx.png
This small example application has displayed 2 Message Boxes, if this
were a larger sized program then the second box which needs to be
clicked OK first would be behind the whole program and only reachable
through ALT TAB or clicking on it in the taskbar. How is this
possible?!?!

Nov 21 '05 #2
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. Call DoStuff() ''inside this, "h" set to 123
  71. MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
  72. Else
  73. MsgBox("Random Message")
  74. End If
  75. Catch ex As Exception
  76. ErrorTrap(ex,
  77. System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
  78. End Try
  79. End Sub
  80.  
  81.  
Nov 21 '05 #3
First thing I would do is refactor all the if thens to guard clauses with
custom exceptions instead of exitSub's

http://www.refactoring.com/catalog/r...rdClauses.html

--
--Eric Cathell, MCSA
"jburkle" <jb*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Expand|Select|Wrap|Line Numbers
  1. .....
  2.  Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
  3.  eventArgs As System.EventArgs) Handles cmdRenew.Click
  4.         Try
  5.             If x Is Nothing Then
  6.                 Exit Sub
  7.             End If
  8.             If y > 0 Then
  9.                 If z = 0 Then
  10.                     MsgBox("Random Message")
  11.                     Exit Sub
  12.                 End If
  13.             Else
  14.                 Exit Sub
  15.             End If
  16.             If a Then
  17.                 MessageBox.Show("Random Message")
  18.                 Exit Sub
  19.             End If
  20.             If (b Or c) Then
  21.                 MsgBox("Random Message")
  22.                 Exit Sub
  23.             Else
  24.                 If d Then
  25.                     ...
  26.                     If e Then
  27.                         MsgBox("Random Message")
  28.                         Exit Sub
  29.                     End If
  30.                 Else
  31.                     If f Then
  32.                         ...
  33.                         If g Then
  34.                             MsgBox("Random Message")
  35.                             Exit Sub
  36.                         End If
  37.                     Else
  38.                         MsgBox("Random Message")
  39.                         Exit Sub
  40.                     End If
  41.                 End If
  42.             End If
  43.  ''Problem Here
  44.             If (h = 123) Then
  45.                 MsgBox("This Message Displays to the User while Done!
  46.  MessageBox is also being Displayed")
  47.                 Exit Sub
  48.             End If
  49.             If i <> "" Then
  50.                 ...
  51.                 If j Then
  52.                     MsgBox("Random Message")
  53.                     Exit Sub
  54.                 End If
  55.                 If k Then
  56.                     ...
  57.                 Else
  58.                     If l Then
  59.                         ...
  60.                     Else
  61.                         ...
  62.                     End If
  63.                 End If
  64.  ''Gets to here
  65.                 Call DoStuff() ''inside this, "h" set to 123
  66.                 MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
  67.             Else
  68.                 MsgBox("Random Message")
  69.             End If
  70.         Catch ex As Exception
  71.             ErrorTrap(ex,
  72.  System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
  73.         End Try
  74.  End Sub
  75.  

Nov 21 '05 #4
Is there any place where I can get more information and VB examples
regarding guard clauses?

Thank you.

"ECathell" <ec******@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
First thing I would do is refactor all the if thens to guard clauses with
custom exceptions instead of exitSub's

http://www.refactoring.com/catalog/r...rdClauses.html

--
--Eric Cathell, MCSA
"jburkle" <jb*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Expand|Select|Wrap|Line Numbers
  1. .....
  2.  Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
  3.  eventArgs As System.EventArgs) Handles cmdRenew.Click
  4.         Try
  5.             If x Is Nothing Then
  6.                 Exit Sub
  7.             End If
  8.             If y > 0 Then
  9.                 If z = 0 Then
  10.                     MsgBox("Random Message")
  11.                     Exit Sub
  12.                 End If
  13.             Else
  14.                 Exit Sub
  15.             End If
  16.             If a Then
  17.                 MessageBox.Show("Random Message")
  18.                 Exit Sub
  19.             End If
  20.             If (b Or c) Then
  21.                 MsgBox("Random Message")
  22.                 Exit Sub
  23.             Else
  24.                 If d Then
  25.                     ...
  26.                     If e Then
  27.                         MsgBox("Random Message")
  28.                         Exit Sub
  29.                     End If
  30.                 Else
  31.                     If f Then
  32.                         ...
  33.                         If g Then
  34.                             MsgBox("Random Message")
  35.                             Exit Sub
  36.                         End If
  37.                     Else
  38.                         MsgBox("Random Message")
  39.                         Exit Sub
  40.                     End If
  41.                 End If
  42.             End If
  43.  ''Problem Here
  44.             If (h = 123) Then
  45.                 MsgBox("This Message Displays to the User while Done!
  46.  MessageBox is also being Displayed")
  47.                 Exit Sub
  48.             End If
  49.             If i <> "" Then
  50.                 ...
  51.                 If j Then
  52.                     MsgBox("Random Message")
  53.                     Exit Sub
  54.                 End If
  55.                 If k Then
  56.                     ...
  57.                 Else
  58.                     If l Then
  59.                         ...
  60.                     Else
  61.                         ...
  62.                     End If
  63.                 End If
  64.  ''Gets to here
  65.                 Call DoStuff() ''inside this, "h" set to 123
  66.                 MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
  67.             Else
  68.                 MsgBox("Random Message")
  69.             End If
  70.         Catch ex As Exception
  71.             ErrorTrap(ex,
  72.  System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
  73.         End Try
  74.  End Sub
  75.  


Nov 21 '05 #5
jburkle,

A couple of points:

1. This is ugly code. (But it still should not display 2 message boxes).

2. You are not showing us a subset of your code in which the problem can be
reproduced. For example, you don't show any code for the DoStuff subprocedure.

Can you create a subset of your code that has the problem and that can be
used by others to reproduce the problem? In other words, no ellipses,
subprocedures present, no missing code that might be using threads, etc.

Kerry Moorman
"jburkle" wrote:
Expand|Select|Wrap|Line Numbers
  1. .....
  2.  Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
  3.  eventArgs As System.EventArgs) Handles cmdRenew.Click
  4.          Try
  5.              If x Is Nothing Then
  6.                  Exit Sub
  7.              End If
  8.              If y > 0 Then
  9.                  If z = 0 Then
  10.                      MsgBox("Random Message")
  11.                      Exit Sub
  12.                  End If
  13.              Else
  14.                  Exit Sub
  15.              End If
  16.              If a Then
  17.                  MessageBox.Show("Random Message")
  18.                  Exit Sub
  19.              End If
  20.              If (b Or c) Then
  21.                  MsgBox("Random Message")
  22.                  Exit Sub
  23.              Else
  24.                  If d Then
  25.                      ...
  26.                      If e Then
  27.                          MsgBox("Random Message")
  28.                          Exit Sub
  29.                      End If
  30.                  Else
  31.                      If f Then
  32.                          ...
  33.                          If g Then
  34.                              MsgBox("Random Message")
  35.                              Exit Sub
  36.                          End If
  37.                      Else
  38.                          MsgBox("Random Message")
  39.                          Exit Sub
  40.                      End If
  41.                  End If
  42.              End If
  43.  ''Problem Here
  44.              If (h = 123) Then
  45.                  MsgBox("This Message Displays to the User while Done!
  46.  MessageBox is also being Displayed")
  47.                  Exit Sub
  48.              End If
  49.              If i <> "" Then
  50.                  ...
  51.                  If j Then
  52.                      MsgBox("Random Message")
  53.                      Exit Sub
  54.                  End If
  55.                  If k Then
  56.                      ...
  57.                  Else
  58.                      If l Then
  59.                          ...
  60.                      Else
  61.                          ...
  62.                      End If
  63.                  End If
  64.  ''Gets to here
  65.                  Call DoStuff() ''inside this, "h" set to 123
  66.                  MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
  67.              Else
  68.                  MsgBox("Random Message")
  69.              End If
  70.          Catch ex As Exception
  71.              ErrorTrap(ex,
  72.  System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
  73.          End Try
  74.  End Sub
  75.  

Nov 21 '05 #6
First, you need to give more code here in order for anyone to be able to
reproduce this. Your screenshot shows two message boxes but only one of
them is called from the code you posted. Post everythign you have, and
folks may be able to help you. Include a full screenshot as well, showing
your task bar. I suspect that you have other windows open as part of this
app that may have somethign to do with your problem.

Second, why are you using both messagebox.show() and msgbox() in your code?

Third, this code looks like it does nothgin at all, what exactly are you
trying to test here?

Lastly, why are you posting twice in the same newsgroup for the same issue?
There are still folks replying to yuour first post and you havent responded
to some of their questions/suggestions.
"jburkle" <jb*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Expand|Select|Wrap|Line Numbers
  1. .....
  2.  Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
  3.  eventArgs As System.EventArgs) Handles cmdRenew.Click
  4.          Try
  5.              If x Is Nothing Then
  6.                  Exit Sub
  7.              End If
  8.              If y > 0 Then
  9.                  If z = 0 Then
  10.                      MsgBox("Random Message")
  11.                      Exit Sub
  12.                  End If
  13.              Else
  14.                  Exit Sub
  15.              End If
  16.              If a Then
  17.                  MessageBox.Show("Random Message")
  18.                  Exit Sub
  19.              End If
  20.              If (b Or c) Then
  21.                  MsgBox("Random Message")
  22.                  Exit Sub
  23.              Else
  24.                  If d Then
  25.                      ...
  26.                      If e Then
  27.                          MsgBox("Random Message")
  28.                          Exit Sub
  29.                      End If
  30.                  Else
  31.                      If f Then
  32.                          ...
  33.                          If g Then
  34.                              MsgBox("Random Message")
  35.                              Exit Sub
  36.                          End If
  37.                      Else
  38.                          MsgBox("Random Message")
  39.                          Exit Sub
  40.                      End If
  41.                  End If
  42.              End If
  43.  ''Problem Here
  44.              If (h = 123) Then
  45.                  MsgBox("This Message Displays to the User while Done!
  46.  MessageBox is also being Displayed")
  47.                  Exit Sub
  48.              End If
  49.              If i <> "" Then
  50.                  ...
  51.                  If j Then
  52.                      MsgBox("Random Message")
  53.                      Exit Sub
  54.                  End If
  55.                  If k Then
  56.                      ...
  57.                  Else
  58.                      If l Then
  59.                          ...
  60.                      Else
  61.                          ...
  62.                      End If
  63.                  End If
  64.  ''Gets to here
  65.                  Call DoStuff() ''inside this, "h" set to 123
  66.                  MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
  67.              Else
  68.                  MsgBox("Random Message")
  69.              End If
  70.          Catch ex As Exception
  71.              ErrorTrap(ex,
  72.  System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
  73.          End Try
  74.  End Sub
  75.  

Nov 21 '05 #7
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
  2. eventArgs As System.EventArgs) Handles cmdRenew.Click
  3. Me.EnableFrameSepAddressButtons(False)
  4. Dim strMessage As String
  5. Try
  6. Dim intIndexfield As Integer
  7. Dim strMagId As String
  8. Dim intIssyr As Integer
  9. Dim iProdIssues As Integer
  10. Dim dr_selectMagazine As DataRow
  11. Dim dr_MagInfo As DataRow
  12. Dim dr_loadCustomerInfo As DataRow
  13. Dim dt_RenewalDate As Date
  14.  
  15. 'Implemented 3/31/2003
  16. 'Check the Magazine subscription plan versus the payment
  17. plan first!
  18. If Me.gridMagazineList.DataSource Is Nothing Then
  19. Exit Sub
  20. End If
  21. 'Check the status of the account before continuing.
  22. Accounts that are not PIF
  23. 'wont' be allowed to renew magazines
  24. Dim bm As BindingManagerBase =
  25. Me.gridMagazineList.BindingContext(Me.gridMagazineList.DataSource,
  26. Me.gridMagazineList.DataMember)
  27. If bm.Count > 0 Then
  28. Dim drDataRow As DataRow = CType(bm.Current,
  29. DataRowView).Row
  30. intIndexfield = IfIsNullInt(drDataRow("IndexField"))
  31. If intIndexfield = 0 Then
  32. strMessage = "Invalid Magazine Selection"
  33. Exit Sub
  34. End If
  35. Else
  36. Exit Sub
  37. End If
  38. dr_selectMagazine =
  39. sql_fCustomer.selectMagazine(intIndexfield).Rows(0)
  40. If (dr_selectMagazine("inactive") = 1) Then
  41. strMessage = "The magazine is inactive and cannot be
  42. renewed."
  43. Exit Sub
  44. End If
  45. If (dr_selectMagazine("OD_Status") = 40 Or
  46. dr_selectMagazine("OD_Status") = 94) Or
  47. IfIsNullDate((dr_selectMagazine("OD_Next_prod_date"))) = "" Or
  48. (dr_selectMagazine("Od_numiss") - dr_selectMagazine("od_issuessent"))
  49. <= 0 Then
  50. strMessage = "This magazine has been Cancelled or there
  51. are not more issues left to be Renewed!"
  52. Exit Sub
  53. Else
  54. 'this is the override that allows
  55. 'for Renewal, even if the date isn't close.
  56. If UserInfo.haveAccess("RenewalData_Entry_Override")
  57. Then
  58. 'we do want to prevent too fast of a renewal... 4
  59. month is set by Vikki
  60. If dtoday <
  61. (CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4)) Then
  62. strMessage = "You must wait until [" &
  63. CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4).Date.ToString
  64. & "] to do renewal for this magazine."
  65. Exit Sub
  66. End If
  67. Else
  68. dr_loadCustomerInfo =
  69. sql_fCustomer.loadCustomerInfo(lngCustNumber, mnordernumber).Rows(0)
  70. 'adding "IfIsNullSng" to Order_Amount_Due
  71. strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
  72. dr_MagInfo =
  73. sql_fCustomer.MagInfo(strMagId).Rows(0)
  74. 'need to be able to renew single year half PIFs
  75. ' (dr_loadCustomerInfo("order_current_status") =
  76. 109)
  77.  
  78. If ((dr_loadCustomerInfo("order_current_status") =
  79. 109)) Or _
  80. (dr_loadCustomerInfo("order_current_status") =
  81. 89) Or ((dr_loadCustomerInfo("Order_current_status") = 39) _
  82. And
  83. (IfIsNullSingle(dr_loadCustomerInfo("Order_Amount_Due")) <
  84. IfIsNullSingle(dr_loadCustomerInfo("Order_current_monthly_Payment"))))
  85. Then
  86. dt_RenewalDate =
  87. (CDate(dr_selectMagazine("OD_Prod_Date_1")).AddYears( _
  88. (CSng(dr_selectMagazine("OD_Issuessent")) /
  89. CSng(dr_selectMagazine("OD_Issues_Year"))))).AddMonths(-3)
  90. If dtoday <= dt_RenewalDate Then
  91. strMessage = "The current production for
  92. this magazine hasn't expired yet, the next possible order date is after
  93. [" & dt_RenewalDate & "]"
  94. Exit Sub
  95. End If
  96. Else
  97. strMessage = "This account needs to be PIF or
  98. in good standing in order to renew Magazines!"
  99. Exit Sub
  100. End If
  101. End If
  102. End If
  103.  
  104. If (dr_selectMagazine("OD_Status") = 123) Then
  105. strMessage = "The magazine is waiting production,
  106. renewing at the moment.  It cannot be renewed again until after next
  107. production."
  108. Exit Sub
  109. End If
  110. 'Gets Information from tblMags on a specific magazine
  111. strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
  112. If strMagId <> "" Then
  113. dr_MagInfo = sql_fCustomer.MagInfo(strMagId).Rows(0)
  114. intIssyr = dr_MagInfo("IssYr")
  115. If dr_MagInfo("inactive") Then
  116. strMessage = "This magazine is Inactive!"
  117. Exit Sub
  118. End If
  119. 'The total # of issues left will be ordered, unless the
  120. magazine is only for 1 year or the the maximum
  121. '# of issues that can be sent is less than the issues
  122. left
  123. If dr_MagInfo("MagSingYear") Then
  124. iProdIssues = intIssyr
  125. Else
  126. 'Magazines, unless the MaxISS is smaller
  127. (fulfillment house won't let us order any more).
  128. If dr_MagInfo("MaxIss") >
  129. dr_selectMagazine("OD_NUMIss") - dr_selectMagazine("Od_Issuessent")
  130. Then
  131. iProdIssues = dr_selectMagazine("OD_NUMIss") -
  132. dr_selectMagazine("Od_issuessent")
  133. Else
  134. iProdIssues = dr_MagInfo("MaxIss")
  135. End If
  136. End If
  137.  
  138. sql_fCustomer.ProductionRenewal_Queue(lngCustNumber,
  139. mnordernumber, intIndexfield, iProdIssues, dtoday, intIssyr, strMagId,
  140. False)
  141.  
  142. sql_fCustomer.InsertMagEdit_Queue((dr_selectMagazine("Custnum")),
  143. (dr_selectMagazine("Ordernum")), intIndexfield, "Renewed Magazine by
  144. using the renew button: " & dr_selectMagazine("OD_Mag_ID"),
  145. (UserInfo.userID), True)
  146. strMessage = "Done!"
  147. LoadMagInfo()
  148. Exit Sub
  149. Else
  150. strMessage = "MagID is blank"
  151. Exit Sub
  152. End If
  153. Catch ex As Exception
  154. ErrorTrap(ex,
  155. System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
  156. Finally
  157. If Not strMessage Is Nothing Then
  158. MessageBox.Show(Me, strMessage, "",
  159. MessageBoxButtons.OK, MessageBoxIcon.Information)
  160. End If
  161. Me.EnableFrameSepAddressButtons(True)
  162. End Try
  163. End Sub
  164.  
  165.  
Expand|Select|Wrap|Line Numbers
  1. Public Sub LoadMagInfo()
  2.  
  3. Dim dtMagInfo As DataTable
  4. Dim iIndex As Integer
  5. Dim strOD_Status As String
  6. Dim dtDataTable As DataTable
  7.  
  8. Try
  9. gridMagazineList.Redraw = False
  10. dtMagInfo = sql_fCustomer.LoadMagazineInfo(lngCustNumber,
  11. mnordernumber)
  12. If dtMagInfo.Rows.Count > 0 Then
  13. dtMagInfo.TableName = "Magazine List"
  14. strOD_Status = dtMagInfo.Rows(0)("OD_Status")
  15.  
  16. 'if the status is "UQ" we don't allow magazine change
  17. TDP-05/07/04 >>>
  18. If (strOD_Status = "Under Query") Then
  19. EnableButtons(False)
  20. Else
  21. EnableButtons(True)
  22. End If
  23. 'TDP-05/07/04   <<<
  24.  
  25. For iIndex = 0 To dtMagInfo.Rows.Count - 1
  26. strOD_Status = dtMagInfo.Rows(iIndex)("OD_Status")
  27. If (strOD_Status.Trim = "PendingCancel") Then
  28. dtMagInfo.Rows(iIndex)("OD_Status") =
  29. "Cancelled"
  30. End If
  31.  
  32. If (dtMagInfo.Rows(iIndex)("UMC_NotUnique")) Then
  33. dtDataTable =
  34. sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
  35. _
  36.  
  37. dtMagInfo.Rows(iIndex)("Ship_State"))
  38. If dtDataTable.Rows.Count > 0 Then
  39. dtMagInfo.Rows(iIndex)("MagName") =
  40. dtDataTable.Rows(0)("MagName") & " (" &
  41. dtMagInfo.Rows(iIndex)("MagName") & ")"
  42. End If
  43.  
  44. End If
  45. Next
  46.  
  47. dtMagInfo.DefaultView.AllowNew = False
  48. gridMagazineList.DataSource = dtMagInfo
  49.  
  50. End If
  51.  
  52. Call SetupgridMagazineList()
  53.  
  54. gridMagazineList.Redraw = True
  55. Call LoadComplaintInfo()
  56. SetUpPermissions()
  57. Catch ex As Exception
  58. If ex.GetType Is GetType(System.IndexOutOfRangeException)
  59. Or _
  60. ex.GetType Is GetType(System.ArgumentException) Then
  61.  
  62. ErrorTrapNoMsgBox(ex,
  63. System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreating Grid")
  64.  
  65.  
  66. Me.tabCust_CustomerInformation.Controls.Remove(Me.gridMagazineList)
  67. Dim gridMagazineList2 As New
  68. LazarusControls.FlexDataGrid
  69. CType(gridMagazineList2,
  70. System.ComponentModel.ISupportInitialize).BeginInit()
  71.  
  72. gridMagazineList2.CaptionText = "Magazine List"
  73. gridMagazineList2.DataMember = ""
  74. gridMagazineList2.HeaderForeColor =
  75. System.Drawing.SystemColors.ControlText
  76. gridMagazineList2.Location = New
  77. System.Drawing.Point(8, 8)
  78. gridMagazineList2.Name = "gridMagazineList"
  79. gridMagazineList2.Size = New System.Drawing.Size(640,
  80. 240)
  81. gridMagazineList2.TabIndex = 194
  82.  
  83. CType(gridMagazineList2,
  84. System.ComponentModel.ISupportInitialize).EndInit()
  85. Me.gridMagazineList = gridMagazineList2
  86.  
  87. Me.tabCust_CustomerInformation.Controls.Add(Me.gridMagazineList)
  88.  
  89. Try
  90. gridMagazineList.Redraw = False
  91. dtMagInfo =
  92. sql_fCustomer.LoadMagazineInfo(lngCustNumber, mnordernumber)
  93. dtMagInfo.TableName = "Magazine List"
  94.  
  95. For iIndex = 0 To dtMagInfo.Rows.Count - 1
  96. strOD_Status =
  97. dtMagInfo.Rows(iIndex)("OD_Status")
  98. If (strOD_Status.Trim = "PendingCancel") Then
  99. dtMagInfo.Rows(iIndex)("OD_Status") =
  100. "Cancelled"
  101. End If
  102.  
  103.  
  104. 'Added on 7/21/2003 for those rogues at Game &
  105. Fish cht
  106. If (dtMagInfo.Rows(iIndex)("UMC_NotUnique"))
  107. Then
  108. dtDataTable =
  109. sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
  110. _
  111.  
  112. dtMagInfo.Rows(iIndex)("Ship_State"))
  113. If dtDataTable.Rows.Count > 0 Then
  114. dtMagInfo.Rows(iIndex)("MagName") =
  115. dtDataTable.Rows(0)("MagName") & " (" &
  116. dtMagInfo.Rows(iIndex)("MagName") & ")"
  117. End If
  118.  
  119. End If
  120. Next
  121.  
  122. dtMagInfo.DefaultView.AllowNew = False
  123. gridMagazineList.DataSource = dtMagInfo
  124.  
  125. Call SetupgridMagazineList()
  126.  
  127. gridMagazineList.Redraw = True
  128. Call LoadComplaintInfo()
  129. Catch ex2 As Exception
  130. ErrorTrap(ex2,
  131. System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreate Grid
  132. Failed")
  133. End Try
  134.  
  135. Else
  136. ErrorTrap(ex,
  137. System.Reflection.MethodInfo.GetCurrentMethod.Name, "" _
  138. )
  139. End If
  140. End Try
  141. End Sub
  142.  
Here is the onclick event that is causing the problem, I thought that
moving the MessageBox Call into the Finally block would fix the
problem, however it hasn't.

Nov 21 '05 #8
I guess the question woudl be which specific lines of code are generating
the two different message boxes you are referring to?
Also, how many seperate windows (forms) do you have open when this occurs,
and which forms are generating each of the message boxes?

"jburkle" <jb*****@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Expand|Select|Wrap|Line Numbers
  1.  Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
  2.  eventArgs As System.EventArgs) Handles cmdRenew.Click
  3.          Me.EnableFrameSepAddressButtons(False)
  4.          Dim strMessage As String
  5.          Try
  6.              Dim intIndexfield As Integer
  7.              Dim strMagId As String
  8.              Dim intIssyr As Integer
  9.              Dim iProdIssues As Integer
  10.              Dim dr_selectMagazine As DataRow
  11.              Dim dr_MagInfo As DataRow
  12.              Dim dr_loadCustomerInfo As DataRow
  13.              Dim dt_RenewalDate As Date
  14.              'Implemented 3/31/2003
  15.              'Check the Magazine subscription plan versus the payment
  16.  plan first!
  17.              If Me.gridMagazineList.DataSource Is Nothing Then
  18.                  Exit Sub
  19.              End If
  20.              'Check the status of the account before continuing.
  21.  Accounts that are not PIF
  22.              'wont' be allowed to renew magazines
  23.              Dim bm As BindingManagerBase =
  24.  Me.gridMagazineList.BindingContext(Me.gridMagazineList.DataSource,
  25.  Me.gridMagazineList.DataMember)
  26.              If bm.Count > 0 Then
  27.                  Dim drDataRow As DataRow = CType(bm.Current,
  28.  DataRowView).Row
  29.                  intIndexfield = IfIsNullInt(drDataRow("IndexField"))
  30.                  If intIndexfield = 0 Then
  31.                      strMessage = "Invalid Magazine Selection"
  32.                      Exit Sub
  33.                  End If
  34.              Else
  35.                  Exit Sub
  36.              End If
  37.              dr_selectMagazine =
  38.  sql_fCustomer.selectMagazine(intIndexfield).Rows(0)
  39.              If (dr_selectMagazine("inactive") = 1) Then
  40.                  strMessage = "The magazine is inactive and cannot be
  41.  renewed."
  42.                  Exit Sub
  43.              End If
  44.              If (dr_selectMagazine("OD_Status") = 40 Or
  45.  dr_selectMagazine("OD_Status") = 94) Or
  46.  IfIsNullDate((dr_selectMagazine("OD_Next_prod_date"))) = "" Or
  47.  (dr_selectMagazine("Od_numiss") - dr_selectMagazine("od_issuessent"))
  48.  <= 0 Then
  49.                  strMessage = "This magazine has been Cancelled or there
  50.  are not more issues left to be Renewed!"
  51.                  Exit Sub
  52.              Else
  53.                  'this is the override that allows
  54.                  'for Renewal, even if the date isn't close.
  55.                  If UserInfo.haveAccess("RenewalData_Entry_Override")
  56.  Then
  57.                      'we do want to prevent too fast of a renewal... 4
  58.  month is set by Vikki
  59.                      If dtoday <
  60.  (CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4)) Then
  61.                          strMessage = "You must wait until [" &
  62.  CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4).Date.ToString
  63.  & "] to do renewal for this magazine."
  64.                          Exit Sub
  65.                      End If
  66.                  Else
  67.                      dr_loadCustomerInfo =
  68.  sql_fCustomer.loadCustomerInfo(lngCustNumber, mnordernumber).Rows(0)
  69.                      'adding "IfIsNullSng" to Order_Amount_Due
  70.                      strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
  71.                      dr_MagInfo =
  72.  sql_fCustomer.MagInfo(strMagId).Rows(0)
  73.                      'need to be able to renew single year half PIFs
  74.                      ' (dr_loadCustomerInfo("order_current_status") =
  75.  109)
  76.                      If ((dr_loadCustomerInfo("order_current_status") =
  77.  109)) Or _
  78.                           (dr_loadCustomerInfo("order_current_status") =
  79.  89) Or ((dr_loadCustomerInfo("Order_current_status") = 39) _
  80.                           And
  81.  (IfIsNullSingle(dr_loadCustomerInfo("Order_Amount_Due")) <
  82.  IfIsNullSingle(dr_loadCustomerInfo("Order_current_monthly_Payment"))))
  83.  Then
  84.                          dt_RenewalDate =
  85.  (CDate(dr_selectMagazine("OD_Prod_Date_1")).AddYears( _
  86.                              (CSng(dr_selectMagazine("OD_Issuessent")) /
  87.  CSng(dr_selectMagazine("OD_Issues_Year"))))).AddMonths(-3)
  88.                          If dtoday <= dt_RenewalDate Then
  89.                              strMessage = "The current production for
  90.  this magazine hasn't expired yet, the next possible order date is after
  91.  [" & dt_RenewalDate & "]"
  92.                              Exit Sub
  93.                          End If
  94.                      Else
  95.                          strMessage = "This account needs to be PIF or
  96.  in good standing in order to renew Magazines!"
  97.                          Exit Sub
  98.                      End If
  99.                  End If
  100.              End If
  101.              If (dr_selectMagazine("OD_Status") = 123) Then
  102.                  strMessage = "The magazine is waiting production,
  103.  renewing at the moment.  It cannot be renewed again until after next
  104.  production."
  105.                  Exit Sub
  106.              End If
  107.              'Gets Information from tblMags on a specific magazine
  108.              strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
  109.              If strMagId <> "" Then
  110.                  dr_MagInfo = sql_fCustomer.MagInfo(strMagId).Rows(0)
  111.                  intIssyr = dr_MagInfo("IssYr")
  112.                  If dr_MagInfo("inactive") Then
  113.                      strMessage = "This magazine is Inactive!"
  114.                      Exit Sub
  115.                  End If
  116.                  'The total # of issues left will be ordered, unless the
  117.  magazine is only for 1 year or the the maximum
  118.                  '# of issues that can be sent is less than the issues
  119.  left
  120.                  If dr_MagInfo("MagSingYear") Then
  121.                      iProdIssues = intIssyr
  122.                  Else
  123.                      'Magazines, unless the MaxISS is smaller
  124.  (fulfillment house won't let us order any more).
  125.                      If dr_MagInfo("MaxIss") >
  126.  dr_selectMagazine("OD_NUMIss") - dr_selectMagazine("Od_Issuessent")
  127.  Then
  128.                          iProdIssues = dr_selectMagazine("OD_NUMIss") -
  129.  dr_selectMagazine("Od_issuessent")
  130.                      Else
  131.                          iProdIssues = dr_MagInfo("MaxIss")
  132.                      End If
  133.                  End If
  134.                  sql_fCustomer.ProductionRenewal_Queue(lngCustNumber,
  135.  mnordernumber, intIndexfield, iProdIssues, dtoday, intIssyr, strMagId,
  136.  False)
  137.  sql_fCustomer.InsertMagEdit_Queue((dr_selectMagazine("Custnum")),
  138.  (dr_selectMagazine("Ordernum")), intIndexfield, "Renewed Magazine by
  139.  using the renew button: " & dr_selectMagazine("OD_Mag_ID"),
  140.  (UserInfo.userID), True)
  141.                  strMessage = "Done!"
  142.                  LoadMagInfo()
  143.                  Exit Sub
  144.              Else
  145.                  strMessage = "MagID is blank"
  146.                  Exit Sub
  147.              End If
  148.          Catch ex As Exception
  149.              ErrorTrap(ex,
  150.  System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
  151.          Finally
  152.              If Not strMessage Is Nothing Then
  153.                  MessageBox.Show(Me, strMessage, "",
  154.  MessageBoxButtons.OK, MessageBoxIcon.Information)
  155.              End If
  156.              Me.EnableFrameSepAddressButtons(True)
  157.          End Try
  158.      End Sub
  159.  
Expand|Select|Wrap|Line Numbers
  1.  Public Sub LoadMagInfo()
  2.          Dim dtMagInfo As DataTable
  3.          Dim iIndex As Integer
  4.          Dim strOD_Status As String
  5.          Dim dtDataTable As DataTable
  6.          Try
  7.              gridMagazineList.Redraw = False
  8.              dtMagInfo = sql_fCustomer.LoadMagazineInfo(lngCustNumber,
  9.  mnordernumber)
  10.              If dtMagInfo.Rows.Count > 0 Then
  11.                  dtMagInfo.TableName = "Magazine List"
  12.                  strOD_Status = dtMagInfo.Rows(0)("OD_Status")
  13.                  'if the status is "UQ" we don't allow magazine change
  14.      TDP-05/07/04 >>>
  15.                  If (strOD_Status = "Under Query") Then
  16.                      EnableButtons(False)
  17.                  Else
  18.                      EnableButtons(True)
  19.                  End If
  20.                  'TDP-05/07/04   <<<
  21.                  For iIndex = 0 To dtMagInfo.Rows.Count - 1
  22.                      strOD_Status = dtMagInfo.Rows(iIndex)("OD_Status")
  23.                      If (strOD_Status.Trim = "PendingCancel") Then
  24.                          dtMagInfo.Rows(iIndex)("OD_Status") =
  25.  "Cancelled"
  26.                      End If
  27.                      If (dtMagInfo.Rows(iIndex)("UMC_NotUnique")) Then
  28.                          dtDataTable =
  29.  sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
  30.  _
  31.  dtMagInfo.Rows(iIndex)("Ship_State"))
  32.                          If dtDataTable.Rows.Count > 0 Then
  33.                              dtMagInfo.Rows(iIndex)("MagName") =
  34.  dtDataTable.Rows(0)("MagName") & " (" &
  35.  dtMagInfo.Rows(iIndex)("MagName") & ")"
  36.                          End If
  37.                      End If
  38.                  Next
  39.                  dtMagInfo.DefaultView.AllowNew = False
  40.                  gridMagazineList.DataSource = dtMagInfo
  41.              End If
  42.              Call SetupgridMagazineList()
  43.              gridMagazineList.Redraw = True
  44.              Call LoadComplaintInfo()
  45.              SetUpPermissions()
  46.          Catch ex As Exception
  47.              If ex.GetType Is GetType(System.IndexOutOfRangeException)
  48.  Or _
  49.                  ex.GetType Is GetType(System.ArgumentException) Then
  50.                  ErrorTrapNoMsgBox(ex,
  51.  System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreating Grid")
  52.  Me.tabCust_CustomerInformation.Controls.Remove(Me.gridMagazineList)
  53.                  Dim gridMagazineList2 As New
  54.  LazarusControls.FlexDataGrid
  55.                  CType(gridMagazineList2,
  56.  System.ComponentModel.ISupportInitialize).BeginInit()
  57.                  gridMagazineList2.CaptionText = "Magazine List"
  58.                  gridMagazineList2.DataMember = ""
  59.                  gridMagazineList2.HeaderForeColor =
  60.  System.Drawing.SystemColors.ControlText
  61.                  gridMagazineList2.Location = New
  62.  System.Drawing.Point(8, 8)
  63.                  gridMagazineList2.Name = "gridMagazineList"
  64.                  gridMagazineList2.Size = New System.Drawing.Size(640,
  65.  240)
  66.                  gridMagazineList2.TabIndex = 194
  67.                  CType(gridMagazineList2,
  68.  System.ComponentModel.ISupportInitialize).EndInit()
  69.                  Me.gridMagazineList = gridMagazineList2
  70.  Me.tabCust_CustomerInformation.Controls.Add(Me.gridMagazineList)
  71.                  Try
  72.                      gridMagazineList.Redraw = False
  73.                      dtMagInfo =
  74.  sql_fCustomer.LoadMagazineInfo(lngCustNumber, mnordernumber)
  75.                      dtMagInfo.TableName = "Magazine List"
  76.                      For iIndex = 0 To dtMagInfo.Rows.Count - 1
  77.                          strOD_Status =
  78.  dtMagInfo.Rows(iIndex)("OD_Status")
  79.                          If (strOD_Status.Trim = "PendingCancel") Then
  80.                              dtMagInfo.Rows(iIndex)("OD_Status") =
  81.  "Cancelled"
  82.                          End If
  83.                          'Added on 7/21/2003 for those rogues at Game &
  84.  Fish cht
  85.                          If (dtMagInfo.Rows(iIndex)("UMC_NotUnique"))
  86.  Then
  87.                              dtDataTable =
  88.  sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
  89.  _
  90.  dtMagInfo.Rows(iIndex)("Ship_State"))
  91.                              If dtDataTable.Rows.Count > 0 Then
  92.                                  dtMagInfo.Rows(iIndex)("MagName") =
  93.  dtDataTable.Rows(0)("MagName") & " (" &
  94.  dtMagInfo.Rows(iIndex)("MagName") & ")"
  95.                              End If
  96.                          End If
  97.                      Next
  98.                      dtMagInfo.DefaultView.AllowNew = False
  99.                      gridMagazineList.DataSource = dtMagInfo
  100.                      Call SetupgridMagazineList()
  101.                      gridMagazineList.Redraw = True
  102.                      Call LoadComplaintInfo()
  103.                  Catch ex2 As Exception
  104.                      ErrorTrap(ex2,
  105.  System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreate Grid
  106.  Failed")
  107.                  End Try
  108.              Else
  109.                  ErrorTrap(ex,
  110.  System.Reflection.MethodInfo.GetCurrentMethod.Name, "" _
  111.                          )
  112.              End If
  113.          End Try
  114.      End Sub
  115.  

Here is the onclick event that is causing the problem, I thought that
moving the MessageBox Call into the Finally block would fix the
problem, however it hasn't.

Nov 21 '05 #9
I am sorry if I am confusing anyone with this issue, the thing is that
I can't replicate the issue on our testing system, but it happens to
the end user and does so for different users on different computers.

the code is being called from a button that is on a
System.Windows.Forms.GroupBox which is in a
System.Windows.Forms.TabControl which is in the fCustomer.vb form.

this fCustomer.vb form is in the main mdi.vb form for the program.

The 2 message boxs displayed are the "Done!" box when it does the
updating in the end, and also the "The magazine is waiting production,
renewing at the moment. It cannot be renewed again until after next
production." message box at the OD_status = 123 check........ when the
"Done!" is reached the code before it sets OD_status = 123..... but i
looked for where it could be called again inside the onclick and
couldnt find it, also i added the EnableButtons(false) call to disable
all buttons to try and ensure that the user cant double click them.

Nov 21 '05 #10
This is odd...

Both of those lines of code appear to set strMessage and then exit the
subroutine without triggering the MessageBox.Show call at the end. I don't
understand how either of the messages are being generated by this code at
all. Moving the MessageBox.Show to the end should prevent all messages from
being displayed, as you are not allowing the code to get to that point. Is
it possible that the messages are actually being displayed someplace else in
your code? In another subroutine perhaps?

I suspect that somewhere along the line you are calling two simultaneous
functions in different forms, each of which are displaying a message. I'm
not sure how you would do this, but I can't see how this code would cause
the problem you are having.

"jburkle" <jb*****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
I am sorry if I am confusing anyone with this issue, the thing is that
I can't replicate the issue on our testing system, but it happens to
the end user and does so for different users on different computers.

the code is being called from a button that is on a
System.Windows.Forms.GroupBox which is in a
System.Windows.Forms.TabControl which is in the fCustomer.vb form.

this fCustomer.vb form is in the main mdi.vb form for the program.

The 2 message boxs displayed are the "Done!" box when it does the
updating in the end, and also the "The magazine is waiting production,
renewing at the moment. It cannot be renewed again until after next
production." message box at the OD_status = 123 check........ when the
"Done!" is reached the code before it sets OD_status = 123..... but i
looked for where it could be called again inside the onclick and
couldnt find it, also i added the EnableButtons(false) call to disable
all buttons to try and ensure that the user cant double click them.

Nov 21 '05 #11
i did have 10-15 MessageBox calls throughout all the if/then/else
blocks, but instead i tried to fix the problem by setting a string to
the message i would display, then in the Finally block if that string
was set to Anything then output a MessageBox with that string as the
message..... i thought that this would "fix" the issue with multiple
Message Boxes being displayed however it didn't so i am still suck with
the problem.

I am looking into the other methods called in this onclick() to see if
they display a message box but i checked before and didnt see any.

Nov 21 '05 #12
i think the problem is in the calls to MessageBox...... is there any
differences between calling MessageBox.Show() and creating a custom
form that acts like a message box by calling form.ShowDialog()?

Nov 21 '05 #13

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

Similar topics

8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
1
by: Steve Grahovac | last post by:
I have been having trouble the last few days opening any ASP.NET web forms in the design view in the designer. Every time I clicked on an aspx file I got a message box with the error "Unable to...
4
by: Cris Rock | last post by:
In my ASP.Net application, validation rule demands that user has to select one of the option buton(...WebControls.RadioButton). I am doing these kind of validations in the server side when the user...
1
by: Mark | last post by:
Hello all - I'm not sure if this is an ASP.Net issue or a Crystal Reports issue but I built a web reporting website that runs under SSL. The way the reports are displayed to the user has it where...
9
by: JTrigger | last post by:
When I compile my project using the IDE on a development machine it works just fine. When I compile it on the server using csc.exe, I get the following error when I try to bring it up in the web...
1
by: Jens Øster | last post by:
Hi I am writing a ASP.NET web application that must sent some e-mails. I get the exception “Could not access 'CDO.Message' object” when I call SmtpMail.Send. This only happens when I send...
3
by: Richard Finnigan | last post by:
Hi I was wondering if anyone could help me with this problem. I've been using VWD and my webhost ( a shared hosting package) have told me that the MSQL express files wont work on thier server so...
5
by: Alex A. | last post by:
I have this web application that runs for about 5 minutes doing to database processing, about 50% of the time I get the error message Thread was being aborted. I am looking for hint at where to...
13
by: Ivan Weiss | last post by:
Good morning all, I am trying to access an access database to authenticate users upon logging into my application. Something is throwing an excecption. My error handling code should display...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.