![]() |
Array Problems
1 Attachment(s)
Hello,
My problem here is that I am trying to print a form that stores the name of the selectedindex and the price side by side as you select one of the seat types. I keep getting the seats displaying on knew lines individually with their prices, but I don't want them to display individually, I want the price in the printpreview area to show the added price of the same seat when I click the print summary, not a knew line displaying that it was selected twice. Their is no summary form, just one form and an option to print your results. I have attached a picture of the form so you can see what it looks like. I only am showing a little of the code to keep things simple, and only one seat since the rest would be redundant I think. Public Class clubForm ' Declare structure and module-level variables Structure clubSale Dim typeString As String Dim quantityString As String Dim priceDecimal As Decimal End Structure Private transactionclubSale(20) As clubSale Private numberTransactionsInteger As Integer Private priceDecimal() As Decimal = {40D, 27.5D, 15D, 10D} Private selectedListString As String Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click ' Close the project. Me.Close() End Sub Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click ' Look up the price using the type of seating. Dim rowInteger As Integer Dim salePriceDecimal As Decimal With Me ' Allow only 20 transactions. If numberTransactionsInteger < 20 Then rowInteger = .clubListBox.SelectedIndex If rowInteger <> -1 Then Select Case selectedListString Case "Orchestra" rowInteger = 0 transactionclubSale(numberTransactionsInteger).typeString = "Orchestra" End Select ' Retrieve price of selection salePriceDecimal = priceDecimal(0) priceTextBox.Text = salePriceDecimal.ToString("C") ' Save this transaction. transactionclubSale(numberTransactionsInteger).typeString = .clubListBox.Text transactionclubSale(numberTransactionsInteger).priceDecimal = salePriceDecimal numberTransactionsInteger += 1 End If End If End With Please share your thoughts on this. Thank you. |
Re: Array Problems
Firstly, please wrap your code in between [code] [/code] tags for readability.
Could you clarify what the print summary button does? Quote:
This is what I think you were trying to say: if you click calculate twice over "Orchestra", click calculate once over "Mezzanine", and then click "Print Summary", you get the price displayed for Orchestra+Orchestra+Mezzanine? |
Re: Array Problems
Someone here told me about the code thing before, but I didn't know it has to be enclosed in code blocks like that, I will remember, thank you and sorry for the mess.
The print summary button opens a print preview window showing the amount of seats ordered, the type of seat, and the total price of that particular seats orders (See Below). I am not worried about the amount of seat orders number right now, because I haven't coded for it. But it should show the total amount for any seat choosen. For example when the print summary button is hit a window pops up showing the following. Orchestra $120.00 (because everytime orchestra is clicked 40 gets added to the total. Mezzanine $30.00 (because everytime mezzanine is choosen 15 is added and it the seat is displayed on a knew line.) etc.. Right now it looks like this when I click the button Orchestra $40 orchestra $40 orchestra $40 Mezzanine $15 Mezzanine $15 |
Re: Array Problems
Quote:
You should loop through the transactionclubSale array, and keep track of how many are type "Orchestra". Keep a total for that. Output the total price (the sum of each priceDecimal), and the number of entries found (seats ordered).Repeat for Mezzanine. Repeat for General. Etc... |
Re: Array Problems
So to loop I should code something like this.
:
transactionclubSale(numberTransactionsInteger).typeString = "Orchestra" |
Re: Array Problems
When the printsummary is called you should do something along the lines of:
:
There are more efficient ways of doing this, but that would be the easiest way with your level of programming experience. |
Re: Array Problems
I understand.
I wanted to use arrays, so when you say more efficient are you referring to arrays? I know that my level of programming is rather novice, but I would like to know the more efficient ways if you could please tell me. |
Re: Array Problems
Yes, you could combine all 4 of those repetitions into 1 loop, by using an array to store each individual type's count. Where each type corresponds to a location in the array.
:
seats = new array of size 4, all set to 0But I would advise you try the first method before moving onto something more complicated, if you're a novice just starting to learn how to program. |
| All times are GMT -5. The time now is 3:49 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC