benshaws
Hobbyist Programmer
I have a problem with a MessageBox YesNo when sending output to the printer. The MessageBox appears on screen and closes if Yes is selected by the user, which is as wanted.
However, if No is selected I want to reprint the document. To do this I show another MessageBox with RetryCancel and some code to loop printing. I don't understand why but none of the 'No' code is executed.
Is it something to do with output going to the printer?
Any help would be very much appreciated.
The application is for my wife's shop and I need to be able to do a reprint if the printer jams.
See code below.........................
VS 2019.
.Net Framework 4.7.2
I hope left hand align is OK. Or should I indent when posting on the forum.
However, if No is selected I want to reprint the document. To do this I show another MessageBox with RetryCancel and some code to loop printing. I don't understand why but none of the 'No' code is executed.
Is it something to do with output going to the printer?
Any help would be very much appreciated.
The application is for my wife's shop and I need to be able to do a reprint if the printer jams.
See code below.........................
VS 2019.
.Net Framework 4.7.2
VB.NET:
'Confirm if receipt printed correctly with the user.
Dim resultDlg As Integer
resultDlg = MessageBox.Show("Karen," & Chr(10) & Chr(10) & "Did your receipt print ok?", "Receipt Printing", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
'Reprint the receipt if not printed.
If resultDlg = DialogResult.No Then
Dim resultDlg2 As Integer
Do While resultDlg2 = DialogResult.Retry
resultDlg2 = MessageBox.Show("Karen," & Chr(10) & Chr(10) & "Reprint the receipt again?", "Reprint receipt", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question)
ReceiptDocument.PrinterSettings.Copies = 1
ReceiptDocument.DefaultPageSettings.Landscape = True
ReceiptDocument.Print()
Loop
ElseIf resultDlg = DialogResult.Yes Then
'Reset the receipt datatable to empty after printing.
ReceiptDataTable.Clear()
'Set the next page number.
pagenumber = 1 + pagenumber
End If
I hope left hand align is OK. Or should I indent when posting on the forum.