我有以下代码,我试图让"Total Due" & VBTAB & TotalDueTextBox.text
显示在messageBox(lastline)的底部。我只能让它出现在顶部。有什么建议吗?
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
答案 0 :(得分: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