Hi
It is a calculating form to indicate on how many books you bay and the total discount you will get after you click calculate
it is not all the coding in the hole form
just the calculate part
It is not calculating the 15% discount
DiscountTextBox
, discount price
DiscountedTextB ox
it only gifs me a 0.00 amount
ore any of the calculations in the summary group box
QuantitySumText Box
DiscountSumText Box
DiscountedAmoun tSumTextBox
AverageDiscount TextBox
is not calculating at all
Thanks
It is a calculating form to indicate on how many books you bay and the total discount you will get after you click calculate
it is not all the coding in the hole form
just the calculate part
It is not calculating the 15% discount
DiscountTextBox
, discount price
DiscountedTextB ox
it only gifs me a 0.00 amount
ore any of the calculations in the summary group box
QuantitySumText Box
DiscountSumText Box
DiscountedAmoun tSumTextBox
AverageDiscount TextBox
is not calculating at all
Code:
Private Sub> CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click
'Calculate the price and discount
Dim QuantityInteger As Integer
Dim PriceDecimal, ExtendedPriceDecimal, DiscountDecimal, DiscountedPriceDecimal, AverageDiscountDecimal, _
DISCOUNT_RATE_Decimal, ExtendedPriceDecilmal, QuantitySumInteger, DiscountSumDecimal, SaleCountInteger, _
DiscountedSumDecimal, AverageDescountDecimal As Decimal
Try
'Convert quantity to numeric variable
QuantityInteger = Integer.Parse(QuantityTextBox.Text)
Catch ex As Exception
End Try
Try
'Convertprice if quantity was successful.
PriceDecimal = Decimal.Parse(PriceTextBox.Text)
'Calculate values for sale.
ExtendedPriceDecimal = QuantityInteger * PriceDecimal
DiscountDecimal = Decimal.Round( _
(ExtendedPriceDecimal * DISCOUNT_RATE_Decimal), 1)
DiscountedPriceDecimal = ExtendedPriceDecilmal - DiscountDecimal
'Calculate summary values.
QuantitySumInteger += QuantityInteger
DiscountSumDecimal += DiscountDecimal
SaleCountInteger += 1
AverageDiscountDecimal = DiscountSumDecimal / SaleCountInteger
'Format and display answer for the sale
ExtendedPriceTextBox.Text = ExtendedPriceDecimal.ToString("C")
DiscountTextBox.Text = DiscountDecimal.ToString("N")
DiscountedTextBox.Text = DiscountedPriceDecimal.ToString("C")
'Format and display summary values.
QuantitySumTextBox.Text = QuantitySumInteger.ToString()
DiscountTextBox.Text = DiscountedSumDecimal.ToString("C")
AverageDiscountTextBox.Text = AverageDescountDecimal.ToString("C")
Catch PriceException As FormatException
'Handle a price exception
MessageBox.Show("Price must be numeric.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With PriceTextBox
.Focus()
.SelectAll()
End With
End Try
Try
Catch QuantityException As FormatException
'Handle a quantity exception.
MessageBox.Show("Quantity must be numeric. ", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
With QuantityTextBox
.Focus()
.SelectAll()
End With
End Try
End Sub
Thanks
Comment