It is a calculating form IN VB coding 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 in the
DiscountTextBox
, discount price
DiscountedTextBox
it only gives me a 0.00 amount
and the calculations in the summary group box
nothing is adding up
QuantitySumTextBox
DiscountSumTextBox
DiscountedAmountSumTextBox
AverageDiscountTextBox
is not calculating at all
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
Last edited by digioz; 04-16-10 at 09:13 AM.
Reason: Please use code tags