Message Box Issue

J

jburkle

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?!?!
 
J

jburkle

Code:
.....

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

Try
If x Is Nothing Then
Exit Sub
End If
If y > 0 Then
If z = 0 Then
MsgBox("Random Message")
Exit Sub
End If
Else
Exit Sub
End If
If a Then
MessageBox.Show("Random Message")
Exit Sub
End If
If (b Or c) Then
MsgBox("Random Message")
Exit Sub
Else
If d Then
...
If e Then
MsgBox("Random Message")
Exit Sub
End If
Else
If f Then
...
If g Then
MsgBox("Random Message")
Exit Sub
End If
Else
MsgBox("Random Message")
Exit Sub
End If
End If
End If

''Problem Here

If (h = 123) Then
MsgBox("This Message Displays to the User while Done!
MessageBox is also being Displayed")
Exit Sub
End If
If i <> "" Then
...
If j Then
MsgBox("Random Message")
Exit Sub
End If
If k Then
...
Else
If l Then
...
Else
...
End If
End If

''Gets to here
Call DoStuff() ''inside this, "h" set to 123
MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
Else
MsgBox("Random Message")
End If
Catch ex As Exception
ErrorTrap(ex,
System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
End Try
End Sub
 
D

Dragon

Is there any place where I can get more information and VB examples
regarding guard clauses?

Thank you.

ECathell said:
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/replaceNestedConditionalWithGuardClauses.html

--
--Eric Cathell, MCSA
jburkle said:
Code:
.....

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

Try
If x Is Nothing Then
Exit Sub
End If
If y > 0 Then
If z = 0 Then
MsgBox("Random Message")
Exit Sub
End If
Else
Exit Sub
End If
If a Then
MessageBox.Show("Random Message")
Exit Sub
End If
If (b Or c) Then
MsgBox("Random Message")
Exit Sub
Else
If d Then
...
If e Then
MsgBox("Random Message")
Exit Sub
End If
Else
If f Then
...
If g Then
MsgBox("Random Message")
Exit Sub
End If
Else
MsgBox("Random Message")
Exit Sub
End If
End If
End If

''Problem Here

If (h = 123) Then
MsgBox("This Message Displays to the User while Done!
MessageBox is also being Displayed")
Exit Sub
End If
If i <> "" Then
...
If j Then
MsgBox("Random Message")
Exit Sub
End If
If k Then
...
Else
If l Then
...
Else
...
End If
End If

''Gets to here
Call DoStuff() ''inside this, "h" set to 123
MessageBox.Show(me,"Done!", "", MessageBoxButtons.OK)
Else
MsgBox("Random Message")
End If
Catch ex As Exception
ErrorTrap(ex,
System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
End Try
End Sub
 
G

Guest

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
 
J

Jim Underwood

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.
 
J

jburkle

Code:
Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles cmdRenew.Click
Me.EnableFrameSepAddressButtons(False)
Dim strMessage As String
Try
Dim intIndexfield As Integer
Dim strMagId As String
Dim intIssyr As Integer
Dim iProdIssues As Integer
Dim dr_selectMagazine As DataRow
Dim dr_MagInfo As DataRow
Dim dr_loadCustomerInfo As DataRow
Dim dt_RenewalDate As Date

'Implemented 3/31/2003
'Check the Magazine subscription plan versus the payment
plan first!
If Me.gridMagazineList.DataSource Is Nothing Then
Exit Sub
End If
'Check the status of the account before continuing.
Accounts that are not PIF
'wont' be allowed to renew magazines
Dim bm As BindingManagerBase =
Me.gridMagazineList.BindingContext(Me.gridMagazineList.DataSource,
Me.gridMagazineList.DataMember)
If bm.Count > 0 Then
Dim drDataRow As DataRow = CType(bm.Current,
DataRowView).Row
intIndexfield = IfIsNullInt(drDataRow("IndexField"))
If intIndexfield = 0 Then
strMessage = "Invalid Magazine Selection"
Exit Sub
End If
Else
Exit Sub
End If
dr_selectMagazine =
sql_fCustomer.selectMagazine(intIndexfield).Rows(0)
If (dr_selectMagazine("inactive") = 1) Then
strMessage = "The magazine is inactive and cannot be
renewed."
Exit Sub
End If
If (dr_selectMagazine("OD_Status") = 40 Or
dr_selectMagazine("OD_Status") = 94) Or
IfIsNullDate((dr_selectMagazine("OD_Next_prod_date"))) = "" Or
(dr_selectMagazine("Od_numiss") - dr_selectMagazine("od_issuessent"))
<= 0 Then
strMessage = "This magazine has been Cancelled or there
are not more issues left to be Renewed!"
Exit Sub
Else
'this is the override that allows
'for Renewal, even if the date isn't close.
If UserInfo.haveAccess("RenewalData_Entry_Override")
Then
'we do want to prevent too fast of a renewal... 4
month is set by Vikki
If dtoday <
(CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4)) Then
strMessage = "You must wait until [" &
CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4).Date.ToString
& "] to do renewal for this magazine."
Exit Sub
End If
Else
dr_loadCustomerInfo =
sql_fCustomer.loadCustomerInfo(lngCustNumber, mnordernumber).Rows(0)
'adding "IfIsNullSng" to Order_Amount_Due
strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
dr_MagInfo =
sql_fCustomer.MagInfo(strMagId).Rows(0)
'need to be able to renew single year half PIFs
' (dr_loadCustomerInfo("order_current_status") =
109)

If ((dr_loadCustomerInfo("order_current_status") =
109)) Or _
(dr_loadCustomerInfo("order_current_status") =
89) Or ((dr_loadCustomerInfo("Order_current_status") = 39) _
And
(IfIsNullSingle(dr_loadCustomerInfo("Order_Amount_Due")) <
IfIsNullSingle(dr_loadCustomerInfo("Order_current_monthly_Payment"))))
Then
dt_RenewalDate =
(CDate(dr_selectMagazine("OD_Prod_Date_1")).AddYears( _
(CSng(dr_selectMagazine("OD_Issuessent")) /
CSng(dr_selectMagazine("OD_Issues_Year"))))).AddMonths(-3)
If dtoday <= dt_RenewalDate Then
strMessage = "The current production for
this magazine hasn't expired yet, the next possible order date is after
[" & dt_RenewalDate & "]"
Exit Sub
End If
Else
strMessage = "This account needs to be PIF or
in good standing in order to renew Magazines!"
Exit Sub
End If
End If
End If

If (dr_selectMagazine("OD_Status") = 123) Then
strMessage = "The magazine is waiting production,
renewing at the moment.  It cannot be renewed again until after next
production."
Exit Sub
End If
'Gets Information from tblMags on a specific magazine
strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
If strMagId <> "" Then
dr_MagInfo = sql_fCustomer.MagInfo(strMagId).Rows(0)
intIssyr = dr_MagInfo("IssYr")
If dr_MagInfo("inactive") Then
strMessage = "This magazine is Inactive!"
Exit Sub
End If
'The total # of issues left will be ordered, unless the
magazine is only for 1 year or the the maximum
'# of issues that can be sent is less than the issues
left
If dr_MagInfo("MagSingYear") Then
iProdIssues = intIssyr
Else
'Magazines, unless the MaxISS is smaller
(fulfillment house won't let us order any more).
If dr_MagInfo("MaxIss") >
dr_selectMagazine("OD_NUMIss") - dr_selectMagazine("Od_Issuessent")
Then
iProdIssues = dr_selectMagazine("OD_NUMIss") -
dr_selectMagazine("Od_issuessent")
Else
iProdIssues = dr_MagInfo("MaxIss")
End If
End If

sql_fCustomer.ProductionRenewal_Queue(lngCustNumber,
mnordernumber, intIndexfield, iProdIssues, dtoday, intIssyr, strMagId,
False)

sql_fCustomer.InsertMagEdit_Queue((dr_selectMagazine("Custnum")),
(dr_selectMagazine("Ordernum")), intIndexfield, "Renewed Magazine by
using the renew button: " & dr_selectMagazine("OD_Mag_ID"),
(UserInfo.userID), True)
strMessage = "Done!"
LoadMagInfo()
Exit Sub
Else
strMessage = "MagID is blank"
Exit Sub
End If
Catch ex As Exception
ErrorTrap(ex,
System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
Finally
If Not strMessage Is Nothing Then
MessageBox.Show(Me, strMessage, "",
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Me.EnableFrameSepAddressButtons(True)
End Try
End Sub
Code:
Public Sub LoadMagInfo()

Dim dtMagInfo As DataTable
Dim iIndex As Integer
Dim strOD_Status As String
Dim dtDataTable As DataTable

Try
gridMagazineList.Redraw = False
dtMagInfo = sql_fCustomer.LoadMagazineInfo(lngCustNumber,
mnordernumber)
If dtMagInfo.Rows.Count > 0 Then
dtMagInfo.TableName = "Magazine List"
strOD_Status = dtMagInfo.Rows(0)("OD_Status")

'if the status is "UQ" we don't allow magazine change
TDP-05/07/04 >>>
If (strOD_Status = "Under Query") Then
EnableButtons(False)
Else
EnableButtons(True)
End If
'TDP-05/07/04   <<<

For iIndex = 0 To dtMagInfo.Rows.Count - 1
strOD_Status = dtMagInfo.Rows(iIndex)("OD_Status")
If (strOD_Status.Trim = "PendingCancel") Then
dtMagInfo.Rows(iIndex)("OD_Status") =
"Cancelled"
End If

If (dtMagInfo.Rows(iIndex)("UMC_NotUnique")) Then
dtDataTable =
sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
_

dtMagInfo.Rows(iIndex)("Ship_State"))
If dtDataTable.Rows.Count > 0 Then
dtMagInfo.Rows(iIndex)("MagName") =
dtDataTable.Rows(0)("MagName") & " (" &
dtMagInfo.Rows(iIndex)("MagName") & ")"
End If

End If
Next

dtMagInfo.DefaultView.AllowNew = False
gridMagazineList.DataSource = dtMagInfo

End If

Call SetupgridMagazineList()

gridMagazineList.Redraw = True
Call LoadComplaintInfo()
SetUpPermissions()
Catch ex As Exception
If ex.GetType Is GetType(System.IndexOutOfRangeException)
Or _
ex.GetType Is GetType(System.ArgumentException) Then

ErrorTrapNoMsgBox(ex,
System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreating Grid")


Me.tabCust_CustomerInformation.Controls.Remove(Me.gridMagazineList)
Dim gridMagazineList2 As New
LazarusControls.FlexDataGrid
CType(gridMagazineList2,
System.ComponentModel.ISupportInitialize).BeginInit()

gridMagazineList2.CaptionText = "Magazine List"
gridMagazineList2.DataMember = ""
gridMagazineList2.HeaderForeColor =
System.Drawing.SystemColors.ControlText
gridMagazineList2.Location = New
System.Drawing.Point(8, 8)
gridMagazineList2.Name = "gridMagazineList"
gridMagazineList2.Size = New System.Drawing.Size(640,
240)
gridMagazineList2.TabIndex = 194

CType(gridMagazineList2,
System.ComponentModel.ISupportInitialize).EndInit()
Me.gridMagazineList = gridMagazineList2

Me.tabCust_CustomerInformation.Controls.Add(Me.gridMagazineList)

Try
gridMagazineList.Redraw = False
dtMagInfo =
sql_fCustomer.LoadMagazineInfo(lngCustNumber, mnordernumber)
dtMagInfo.TableName = "Magazine List"

For iIndex = 0 To dtMagInfo.Rows.Count - 1
strOD_Status =
dtMagInfo.Rows(iIndex)("OD_Status")
If (strOD_Status.Trim = "PendingCancel") Then
dtMagInfo.Rows(iIndex)("OD_Status") =
"Cancelled"
End If


'Added on 7/21/2003 for those rogues at Game &
Fish cht
If (dtMagInfo.Rows(iIndex)("UMC_NotUnique"))
Then
dtDataTable =
sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
_

dtMagInfo.Rows(iIndex)("Ship_State"))
If dtDataTable.Rows.Count > 0 Then
dtMagInfo.Rows(iIndex)("MagName") =
dtDataTable.Rows(0)("MagName") & " (" &
dtMagInfo.Rows(iIndex)("MagName") & ")"
End If

End If
Next

dtMagInfo.DefaultView.AllowNew = False
gridMagazineList.DataSource = dtMagInfo

Call SetupgridMagazineList()

gridMagazineList.Redraw = True
Call LoadComplaintInfo()
Catch ex2 As Exception
ErrorTrap(ex2,
System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreate Grid
Failed")
End Try

Else
ErrorTrap(ex,
System.Reflection.MethodInfo.GetCurrentMethod.Name, "" _
)
End If
End Try
End Sub

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.
 
J

Jim Underwood

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 said:
Code:
Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles cmdRenew.Click
Me.EnableFrameSepAddressButtons(False)
Dim strMessage As String
Try
Dim intIndexfield As Integer
Dim strMagId As String
Dim intIssyr As Integer
Dim iProdIssues As Integer
Dim dr_selectMagazine As DataRow
Dim dr_MagInfo As DataRow
Dim dr_loadCustomerInfo As DataRow
Dim dt_RenewalDate As Date

'Implemented 3/31/2003
'Check the Magazine subscription plan versus the payment
plan first!
If Me.gridMagazineList.DataSource Is Nothing Then
Exit Sub
End If
'Check the status of the account before continuing.
Accounts that are not PIF
'wont' be allowed to renew magazines
Dim bm As BindingManagerBase =
Me.gridMagazineList.BindingContext(Me.gridMagazineList.DataSource,
Me.gridMagazineList.DataMember)
If bm.Count > 0 Then
Dim drDataRow As DataRow = CType(bm.Current,
DataRowView).Row
intIndexfield = IfIsNullInt(drDataRow("IndexField"))
If intIndexfield = 0 Then
strMessage = "Invalid Magazine Selection"
Exit Sub
End If
Else
Exit Sub
End If
dr_selectMagazine =
sql_fCustomer.selectMagazine(intIndexfield).Rows(0)
If (dr_selectMagazine("inactive") = 1) Then
strMessage = "The magazine is inactive and cannot be
renewed."
Exit Sub
End If
If (dr_selectMagazine("OD_Status") = 40 Or
dr_selectMagazine("OD_Status") = 94) Or
IfIsNullDate((dr_selectMagazine("OD_Next_prod_date"))) = "" Or
(dr_selectMagazine("Od_numiss") - dr_selectMagazine("od_issuessent"))
<= 0 Then
strMessage = "This magazine has been Cancelled or there
are not more issues left to be Renewed!"
Exit Sub
Else
'this is the override that allows
'for Renewal, even if the date isn't close.
If UserInfo.haveAccess("RenewalData_Entry_Override")
Then
'we do want to prevent too fast of a renewal... 4
month is set by Vikki
If dtoday <
(CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4)) Then
strMessage = "You must wait until [" &
CDate(dr_selectMagazine("CurrentProdDate")).AddMonths(4).Date.ToString
& "] to do renewal for this magazine."
Exit Sub
End If
Else
dr_loadCustomerInfo =
sql_fCustomer.loadCustomerInfo(lngCustNumber, mnordernumber).Rows(0)
'adding "IfIsNullSng" to Order_Amount_Due
strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
dr_MagInfo =
sql_fCustomer.MagInfo(strMagId).Rows(0)
'need to be able to renew single year half PIFs
' (dr_loadCustomerInfo("order_current_status") =
109)

If ((dr_loadCustomerInfo("order_current_status") =
109)) Or _
(dr_loadCustomerInfo("order_current_status") =
89) Or ((dr_loadCustomerInfo("Order_current_status") = 39) _
And
(IfIsNullSingle(dr_loadCustomerInfo("Order_Amount_Due")) <
IfIsNullSingle(dr_loadCustomerInfo("Order_current_monthly_Payment"))))
Then
dt_RenewalDate =
(CDate(dr_selectMagazine("OD_Prod_Date_1")).AddYears( _
(CSng(dr_selectMagazine("OD_Issuessent")) /
CSng(dr_selectMagazine("OD_Issues_Year"))))).AddMonths(-3)
If dtoday <= dt_RenewalDate Then
strMessage = "The current production for
this magazine hasn't expired yet, the next possible order date is after
[" & dt_RenewalDate & "]"
Exit Sub
End If
Else
strMessage = "This account needs to be PIF or
in good standing in order to renew Magazines!"
Exit Sub
End If
End If
End If

If (dr_selectMagazine("OD_Status") = 123) Then
strMessage = "The magazine is waiting production,
renewing at the moment.  It cannot be renewed again until after next
production."
Exit Sub
End If
'Gets Information from tblMags on a specific magazine
strMagId = IfIsNullString(Me.txtMagID.Text.Trim)
If strMagId <> "" Then
dr_MagInfo = sql_fCustomer.MagInfo(strMagId).Rows(0)
intIssyr = dr_MagInfo("IssYr")
If dr_MagInfo("inactive") Then
strMessage = "This magazine is Inactive!"
Exit Sub
End If
'The total # of issues left will be ordered, unless the
magazine is only for 1 year or the the maximum
'# of issues that can be sent is less than the issues
left
If dr_MagInfo("MagSingYear") Then
iProdIssues = intIssyr
Else
'Magazines, unless the MaxISS is smaller
(fulfillment house won't let us order any more).
If dr_MagInfo("MaxIss") >
dr_selectMagazine("OD_NUMIss") - dr_selectMagazine("Od_Issuessent")
Then
iProdIssues = dr_selectMagazine("OD_NUMIss") -
dr_selectMagazine("Od_issuessent")
Else
iProdIssues = dr_MagInfo("MaxIss")
End If
End If

sql_fCustomer.ProductionRenewal_Queue(lngCustNumber,
mnordernumber, intIndexfield, iProdIssues, dtoday, intIssyr, strMagId,
False)

sql_fCustomer.InsertMagEdit_Queue((dr_selectMagazine("Custnum")),
(dr_selectMagazine("Ordernum")), intIndexfield, "Renewed Magazine by
using the renew button: " & dr_selectMagazine("OD_Mag_ID"),
(UserInfo.userID), True)
strMessage = "Done!"
LoadMagInfo()
Exit Sub
Else
strMessage = "MagID is blank"
Exit Sub
End If
Catch ex As Exception
ErrorTrap(ex,
System.Reflection.MethodInfo.GetCurrentMethod.Name, "")
Finally
If Not strMessage Is Nothing Then
MessageBox.Show(Me, strMessage, "",
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Me.EnableFrameSepAddressButtons(True)
End Try
End Sub
Code:
Public Sub LoadMagInfo()

Dim dtMagInfo As DataTable
Dim iIndex As Integer
Dim strOD_Status As String
Dim dtDataTable As DataTable

Try
gridMagazineList.Redraw = False
dtMagInfo = sql_fCustomer.LoadMagazineInfo(lngCustNumber,
mnordernumber)
If dtMagInfo.Rows.Count > 0 Then
dtMagInfo.TableName = "Magazine List"
strOD_Status = dtMagInfo.Rows(0)("OD_Status")

'if the status is "UQ" we don't allow magazine change
TDP-05/07/04 >>>
If (strOD_Status = "Under Query") Then
EnableButtons(False)
Else
EnableButtons(True)
End If
'TDP-05/07/04   <<<

For iIndex = 0 To dtMagInfo.Rows.Count - 1
strOD_Status = dtMagInfo.Rows(iIndex)("OD_Status")
If (strOD_Status.Trim = "PendingCancel") Then
dtMagInfo.Rows(iIndex)("OD_Status") =
"Cancelled"
End If

If (dtMagInfo.Rows(iIndex)("UMC_NotUnique")) Then
dtDataTable =
sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
_

dtMagInfo.Rows(iIndex)("Ship_State"))
If dtDataTable.Rows.Count > 0 Then
dtMagInfo.Rows(iIndex)("MagName") =
dtDataTable.Rows(0)("MagName") & " (" &
dtMagInfo.Rows(iIndex)("MagName") & ")"
End If

End If
Next

dtMagInfo.DefaultView.AllowNew = False
gridMagazineList.DataSource = dtMagInfo

End If

Call SetupgridMagazineList()

gridMagazineList.Redraw = True
Call LoadComplaintInfo()
SetUpPermissions()
Catch ex As Exception
If ex.GetType Is GetType(System.IndexOutOfRangeException)
Or _
ex.GetType Is GetType(System.ArgumentException) Then

ErrorTrapNoMsgBox(ex,
System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreating Grid")


Me.tabCust_CustomerInformation.Controls.Remove(Me.gridMagazineList)
Dim gridMagazineList2 As New
LazarusControls.FlexDataGrid
CType(gridMagazineList2,
System.ComponentModel.ISupportInitialize).BeginInit()

gridMagazineList2.CaptionText = "Magazine List"
gridMagazineList2.DataMember = ""
gridMagazineList2.HeaderForeColor =
System.Drawing.SystemColors.ControlText
gridMagazineList2.Location = New
System.Drawing.Point(8, 8)
gridMagazineList2.Name = "gridMagazineList"
gridMagazineList2.Size = New System.Drawing.Size(640,
240)
gridMagazineList2.TabIndex = 194

CType(gridMagazineList2,
System.ComponentModel.ISupportInitialize).EndInit()
Me.gridMagazineList = gridMagazineList2

Me.tabCust_CustomerInformation.Controls.Add(Me.gridMagazineList)

Try
gridMagazineList.Redraw = False
dtMagInfo =
sql_fCustomer.LoadMagazineInfo(lngCustNumber, mnordernumber)
dtMagInfo.TableName = "Magazine List"

For iIndex = 0 To dtMagInfo.Rows.Count - 1
strOD_Status =
dtMagInfo.Rows(iIndex)("OD_Status")
If (strOD_Status.Trim = "PendingCancel") Then
dtMagInfo.Rows(iIndex)("OD_Status") =
"Cancelled"
End If


'Added on 7/21/2003 for those rogues at Game &
Fish cht
If (dtMagInfo.Rows(iIndex)("UMC_NotUnique"))
Then
dtDataTable =
sql_fCustomer.getUniqueMagazineName(dtMagInfo.Rows(iIndex)("OD_Mag_ID"),
_

dtMagInfo.Rows(iIndex)("Ship_State"))
If dtDataTable.Rows.Count > 0 Then
dtMagInfo.Rows(iIndex)("MagName") =
dtDataTable.Rows(0)("MagName") & " (" &
dtMagInfo.Rows(iIndex)("MagName") & ")"
End If

End If
Next

dtMagInfo.DefaultView.AllowNew = False
gridMagazineList.DataSource = dtMagInfo

Call SetupgridMagazineList()

gridMagazineList.Redraw = True
Call LoadComplaintInfo()
Catch ex2 As Exception
ErrorTrap(ex2,
System.Reflection.MethodInfo.GetCurrentMethod.Name, "Recreate Grid
Failed")
End Try

Else
ErrorTrap(ex,
System.Reflection.MethodInfo.GetCurrentMethod.Name, "" _
)
End If
End Try
End Sub

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.
 
J

jburkle

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.
 
J

Jim Underwood

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.
 
J

jburkle

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.
 
J

jburkle

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()?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top