0

我有以下代码,我试图"Total Due" & VBTAB & TotalDueTextBox.text在消息框(最后一行)的底部显示。我只能让它出现在顶部。有什么建议么?

Private Sub TotalSalesByProductToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TotalSalesByProductToolStripMenuItem.Click

    'Display output to immediate window
    Dim RowInteger As Integer
    Dim SalesString As String = "ProductID" & vbTab & vbTab & "Amount" & vbCrLf & "Total Due" & vbTab & vbTab & TotalDueTextBox.Text & vbCrLf

    For Each ProductItem As Product In InventoryProduct
        'Build string to display
        SalesString &= ProductItem.ProductIDString & vbTab & vbTab & ProductSalesTotalDecimal(RowInteger).ToString("C2") & vbCrLf


        'Increment RowInteger
        RowInteger += 1
    Next
    'Display string to a MessageBox
    ' Debug.WriteLine(TotalDueTextBox.Text)

    Dim Answer As String
    Dim MyNote As String

    MyNote = MessageBox.Show(SalesString, "Sales Totals, Do you want to save this File", MessageBoxButtons.OK, MessageBoxIcon.Information)
    MyNote = "Do you want to save the Sales Totals Summary to File?"
    Answer = MsgBox(MyNote, vbYesNo, "Sales Totals to File")

    If Answer = vbNo Then
        'Code for No Responce
    End If

    If Answer = vbYes Then
        'Code for Yes Responce
        sFile.InitialDirectory = ("C:\")
        sFile.FileName = ("Save As...")
        sFile.Filter = ("Only Text Files (*.txt)|*.txt")
        sFile.ShowDialog()

        Dim W As New IO.StreamWriter(sFile.FileName, True)  ' notes from class need messgbox
        W.WriteLine(SalesString)
        W.Close()
    End If
End Sub
4

1 回答 1

0

改变:

Dim SalesString As String = "ProductID" & vbTab & vbTab & "Amount" & vbCrLf & "Total Due" & vbTab & vbTab & TotalDueTextBox.Text & vbCrLf
For Each ProductItem As Product In InventoryProduct
    'Build string to display
    SalesString &= ProductItem.ProductIDString & vbTab & vbTab & ProductSalesTotalDecimal(RowInteger).ToString("C2") & vbCrLf

    'Increment RowInteger
    RowInteger += 1
Next

到:

Dim SalesString As String = "ProductID" & vbTab & vbTab & "Amount" & vbCrLf 
For Each ProductItem As Product In InventoryProduct
    'Build string to display
    SalesString &= ProductItem.ProductIDString & vbTab & vbTab & ProductSalesTotalDecimal(RowInteger).ToString("C2") & vbCrLf

    'Increment RowInteger
    RowInteger += 1
Next
SalesString &= "Total Due" & vbTab & vbTab & TotalDueTextBox.Text & vbCrLf
于 2013-10-11T01:02:17.503 回答