我该如何编辑此消息框?

时间:2018-05-31 06:42:14

标签: vb.net

如何编辑此MessageBox?因为我想在按钮上添加代码。

enter image description here

这是我的代码。如何访问图像中的消息框,以便我可以在按钮上添加If else条件?

Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
Dim t As Integer
Dim s As Integer

xlApp = New Microsoft.Office.Interop.Excel.Application
xlWorkBook = xlApp.Workbooks.Add(xlPath)
xlWorkSheet = xlWorkBook.Sheets("Payment Voucher Printing")

xlWorkSheet.Cells(t + 3, s + 8) = VOUCHER_NUMBERTextBox.Text()
xlWorkSheet.Cells(t + 6, s + 8) = DATE_OF_PAYMENTTextBox.Text()
xlWorkSheet.Cells(t + 7, s + 2) = PAID_TOTextBox.Text()
xlWorkSheet.Cells(t + 12, s + 8) = AMOUNTTextBox.Text()
xlWorkSheet.Cells(t + 12, s + 7) = TOTextBox.Text()
xlWorkSheet.Cells(t + 12, s + 6) = FROMTextBox.Text()
xlWorkSheet.Cells(t + 12, s + 5) = SALES_OF_INVOICE_NUMBERTextBox.Text()
xlWorkSheet.Cells(t + 12, s + 3) = ACTIVITYTextBox.Text()
xlWorkSheet.Cells(t + 12, s + 1) = PAYEE_COMPANYTextBox.Text()
xlWorkSheet.Cells(t + 17, s + 3) = TYPE_OF_EXPENSETextBox.Text()
xlWorkSheet.Cells(t + 20, s + 3) = ACCOUNT_CODETextBox.Text()
xlWorkSheet.Cells(t + 23, s + 3) = CHECKTextBox.Text()
xlWorkSheet.Cells(t + 24, s + 3) = BANKTextBox.Text()
xlWorkSheet.Cells(t + 25, s + 3) = DATE1TextBox.Text()
xlWorkSheet.Cells(t + 22, s + 6) = TYPE_OF_SUPPORTING_DOCUMENTTextBox.Text()
xlWorkSheet.Cells(t + 23, s + 6) = VATABLETextBox.Text()
xlWorkSheet.Cells(t + 24, s + 6) = SUBJECT_TO_W_TAXTextBox.Text()
xlWorkSheet.Cells(t + 25, s + 6) = W_TAX_RATETextBox.Text()
xlWorkSheet.Cells(t + 23, s + 8) = INPUT_VATTextBox.Text()
xlWorkSheet.Cells(t + 24, s + 8) = W_TAXTextBox.Text()
xlWorkSheet.Cells(t + 25, s + 8) = BALANCETextBox.Text()
xlWorkSheet.Cells(t + 21, s + 8) = TOTAL_PHPTextBox.Text()

Try
    xlWorkSheet.SaveAs(xlPath)
    xlWorkBook.Close()
    xlApp.Quit()
Catch ex As Exception
End Try

releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)

MsgBox("You can find the file C:\Users\Desktop\")
Dim res As MsgBoxResult
res = MsgBox("Process completed, Would you like to open file?", MsgBoxStyle.YesNo)
If (res = MsgBoxResult.Yes) Then
    Process.Start(xlpath)
End If

1 个答案:

答案 0 :(得分:0)

您可以按照自己的方式控制和指导此消息框,但这是一项非常困难的任务 您可以在到达此消息框之前自己完成并检查该文件是否可用。如果可用,请提供新文件名

        If System.IO.File.Exists(xlPath) = True Then
        xlPath = Application.StartupPath & "\" & NewFilename & ".xlsx"
    End If