The program is currently working almost as intended, the only thing I still cannot figure out how to do is change the printing from a printed page and into a text window within the program itself. AND... When trying to print the report, it started displaying everything that is in the array and then also adding lines for the newly received items.
It was working and just stopped. AAAAAAAAAAAHHHHHH!
Spoiler:
Code:
' Project: Brimstone Used Album Receiving ' Programmer: Darksiege ' Date: March 2011 ' Description: Chapter 08 Project
Public Class BrimstoneReceiving ' Module Level Declarations ' and Structure
Structure ReceivingInfo Dim BandName As String Dim AlbumName As String Dim QuantityReceived As Integer End Structure
Private ReceivingLists(16) As ReceivingInfo Private NumberTransactionsInteger As Integer Dim Album As ReceivingInfo Dim Artist As ReceivingInfo Dim Received As ReceivingInfo Dim Expected As ReceivingInfo
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click, ExitButton.Click ' Exits the Program Dim ResponseDialogResult As DialogResult
ResponseDialogResult = MessageBox.Show("Print the Report?", "Terminate the Application", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If ResponseDialogResult = DialogResult.Yes Then DisplayButton_Click(sender, e) End If Me.Close() End Sub
Private Sub DisplayButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisplayButton.Click ' Print the report using Print Preview.
PrintPreviewDialog1.Document = PrintDocument1 PrintPreviewDialog1.ShowDialog() End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage ' Handle Print and Print Preview
Dim PrintFont As New Font("Arial", 12) Dim HeadingFont As New Font("Arial", 14, FontStyle.Bold) Dim LineHeightSingle As Single = PrintFont.GetHeight + 2 Dim Column1HorizontalLocationSingle As Single = e.MarginBounds.Left Dim VerticalPrintLocationSingle As Single = e.MarginBounds.Top Dim Column2HorizontalLocationSingle As Single = 300 Dim Column3HorizontalLocationSingle As Single Dim PrintLineString As String Dim FontSizeF As New SizeF Dim FormattedQuantity As Integer
' Set up and display the heading lines PrintLineString = "Brimstone Records Receiving" e.Graphics.DrawString(PrintLineString, HeadingFont, Brushes.Black, Column2HorizontalLocationSingle, VerticalPrintLocationSingle) PrintLineString = "By Darksiege" VerticalPrintLocationSingle += LineHeightSingle e.Graphics.DrawString(PrintLineString, PrintFont, Brushes.Black, Column2HorizontalLocationSingle, VerticalPrintLocationSingle) VerticalPrintLocationSingle += LineHeightSingle * 2
' Loop through the transactions. For Each IndividualAlbumReceive As ReceivingInfo In ReceivingLists ' Don't print if Blank If IndividualAlbumReceive.BandName <> "" Then ' Set up a line.
' Album. e.Graphics.DrawString(IndividualAlbumReceive.AlbumName, PrintFont, Brushes.Black, Column2HorizontalLocationSingle, VerticalPrintLocationSingle)
' Right Align the Quantity column. FormattedQuantity = FormatNumber(IndividualAlbumReceive.QuantityReceived) ' Measure the string in this font FontSizeF = e.Graphics.MeasureString(FormattedQuantity, PrintFont) ' Subtract width of string from column position. Column3HorizontalLocationSingle = 550 - FontSizeF.Width e.Graphics.DrawString(FormattedQuantity, PrintFont, Brushes.Black, Column3HorizontalLocationSingle, VerticalPrintLocationSingle)
' Increment the Y position for the next line; Double Space. VerticalPrintLocationSingle += LineHeightSingle * 2 End If Next End Sub
Private Sub ReceiveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReceiveButton.Click ' Allow only 5 artists received per transaction. Try If NumberTransactionsInteger < 5 Then ' Save this transaction ReceivingLists(NumberTransactionsInteger).BandName = BandNameComboBox.Text ReceivingLists(NumberTransactionsInteger).AlbumName = AlbumNameTextBox.Text ReceivingLists(NumberTransactionsInteger).QuantityReceived = QuantityReceivedTextBox.Text NumberTransactionsInteger += 1 Else MessageBox.Show("Only allow receipt of 5 bands at once.", "Too many records", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End If
'Clear the screen Fields BandNameComboBox.SelectedIndex = -1 AlbumNameTextBox.Text = "" QuantityReceivedTextBox.Text = "" Catch QuantityReceivedException As Exception MessageBox.Show("Quantity Must be entered before receiving.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information) End Try
End Sub
Private Sub BrimstoneReceiving_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Sets the values ReceivingLists(0).BandName = "Duran Duran" ReceivingLists(1).BandName = "Oingo Boingo" ReceivingLists(2).BandName = "Tesla" ReceivingLists(3).BandName = "Testament" ReceivingLists(4).BandName = "Cradle of Filth" ReceivingLists(5).BandName = "Five Finger Death Punch" ReceivingLists(6).BandName = "BananaRama" ReceivingLists(7).BandName = "Slayer" ReceivingLists(8).BandName = "Kiss" ReceivingLists(9).BandName = "Ozzy Osbourne" ReceivingLists(10).BandName = "Tiesto" ReceivingLists(11).BandName = "Paul Oakenfeld" ReceivingLists(12).BandName = "Katy Perry" ReceivingLists(13).BandName = "Pink" ReceivingLists(14).BandName = "Lady GaGa" End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click ' Display the about form
AboutBox1.ShowDialog() End Sub End Class
_________________ Darksiege Traveller, Calé, Whisperer Lead me not into temptation; for I know a shortcut
Last edited by darksiege on Wed Mar 30, 2011 9:11 pm, edited 2 times in total.
You say it stopped working... what happens now when you run it?
Technically... it still works; but, now it displays all of the items in the list, and adds new lines for the items received. it should only be listing items received, not listing all of the items.
As far as the ASCII thing, I am trying to get it to put the same thing it would be printing onto the form itself, If it must be done in ASCII, then yes.
I attempted to use the Print Preview Control (instead of the Dialog) and it told me to bugger off.
EDIT: Okay so I figured out the printing everything even if the qty was 0.... I just changed the line from
Code:
For Each IndividualAlbumReceive As ReceivingInfo In ReceivingLists ' Don't print if Blank If IndividualAlbumReceive.BandName <> "" Then
to
Code:
For Each IndividualAlbumReceive As ReceivingInfo In ReceivingLists ' Don't print if Blank If IndividualAlbumReceive.QuantityReceived > 0 Then
and it began to work as intended, sans the printing/text thing.
_________________ Darksiege Traveller, Calé, Whisperer Lead me not into temptation; for I know a shortcut
It seems first of all you are overwriting the first 5 entries in the pre-existing list with your newly typed stuff when you click the button, instead of putting the new entries at the end of the pre-existing list. You might want to re-design this, although I could be interpreting the code wrong.
If you only want to print the new items then keep a new counter in the For loop in PrintPage. At the end of the loop just have counter += 1. When counter => NumberTransactionsInteger, break out of the for loop. If you haven't done this before I think the keyword is just "break".
To print these out in a text field, you need to define a string such as "FullPageText" or something and set its value to "". Right after anywhere with e.Graphics.DrawString, you need to concatenate either BandName, AlbumName, or FormattedQuantity into this string with a new line.
Note: "\t" is for a tab and "\n" is for a new line, in case you didn't know.
Have a big textfield (or label) called BigTextfield or something. After the for loop finishes just do BigTextfield.text = FullPageText.
I hope I make some sort of sense.
edit:
I see what you mean with quantity received... just disregard my first two paragraphs I guess. Using quantity received seems like the best way to do what you want.
that does make sense, thank you... now if I did not want it to do a print preview at all, and just do the display on the text box, how would I need to modify it?
I have tried a few variations and they all hate me.
_________________ Darksiege Traveller, Calé, Whisperer Lead me not into temptation; for I know a shortcut
that does make sense, thank you... now if I did not want it to do a print preview at all, and just do the display on the text box, how would I need to modify it?
I have tried a few variations and they all hate me.
The fastest and fool-proof way to do this is to comment out any line that has "e.Graphics.DrawString"
The fastest and fool-proof way to do this is to comment out any line that has "e.Graphics.DrawString"
I kind of did that by putting the for loop in the Display button code (second appearance in the code), and leaving the print document option only in the exit button.
I was about to delete the comment but you had already replied.
_________________ Darksiege Traveller, Calé, Whisperer Lead me not into temptation; for I know a shortcut
Users browsing this forum: No registered users and 115 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum