View Single Post
  #1 (permalink)  
Old November 13th, 2012, 01:46 AM
MinusZero MinusZero is offline
Authorized User
Points: 130, Level: 2
Points: 130, Level: 2 Points: 130, Level: 2 Points: 130, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2012
Location: Australia
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
Unhappy Lesson 13 - Try It...Seriously?

Where do I start. This try it is incredibly frustrating. There is code present in the downloaded file that isnt referred to at all in the book. For example, this code:
Code:
 private decimal GrandTotal = 0;
is not mentioned at all, yet I have to add to the grand total and display the new result (without having declared GrandTotal if you follow the book).

The problem (apart from lack of detail) is that in Form 1 in this code
Code:
//get new values
                ListViewItem lvi = itemsListView.Items.Add(frm.ItemName);
                lvi.SubItems.Add(frm.PriceEach.ToString("C"));
                lvi.SubItems.Add(frm.Quantity.ToString("C"));
                lvi.SubItems.Add(frm.TotalPrice.ToString("C"));
I get errors on ItemName, PriceEach, Quantity and TotalPrice even though I have declared them in the NewItemForm:

Code:
public Form1()
        {
            InitializeComponent();
        }
        public string ItemName;
        public decimal PriceEach, Quantity, TotalPrice;

        private void btnCalculate_Click(object sender, EventArgs e)
        {
            ItemName = tbxItem.Text;
            PriceEach = decimal.Parse(tbxPriceEach.Text);
            Quantity = decimal.Parse(tbxQuantity.Text);

            TotalPrice = PriceEach * Quantity;
            tbxTotalPrice.Text=TotalPrice.ToString("C");

            btnOK.Enabled = true;

        }
------------------
This code from the downloaded Lesson 13 Try it contains NumberStyles.Any. When i try to type it, Intellisense doesnt find such an item.

Code:
PriceEach = decimal.Parse(priceEachTextBox.Text, NumberStyles.Any);
I have no idea what is happening and am at my wits end. The book seems to be becoming less helpful as more and more it seems to assume a novice coder has the knowledge to complete something that isnt shown. I might move to the next chapter and live without chapter 13. I dont think it will be a problem.

Oh and one more thing, the book asks you to create the NewItemForm first when you actually want the main form (Form1) to load first. Fortunately the internet helped me work out how to change which form starts first so I didnt have to remake the form.
__________________
"These pretzels are making me thirsty"