Calculate Discount

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shanehenery
    New Member
    • Feb 2010
    • 24

    Calculate Discount

    Hi

    Thanks for your reply my project is working fine
    but how do I change the currency from $ to R
    after I select calculate to display (R1.00) and not ($1.00) in my TextBox
  • MrMancunian
    Recognized Expert Contributor
    • Jul 2008
    • 569

    #2
    Type in an R instead of a $... No, seriously, how the heck are we supposed to know what is wrong if you don't:

    1. Mention the language
    2. Post any code
    3. Explain anything about your project

    My psychic powers are not that good my friend!

    Steven

    Comment

    • shanehenery
      New Member
      • Feb 2010
      • 24

      #3
      Hi
      I am using vb.net
      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
      Code:
      '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
      
          Private Sub RnR_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      
          End Sub
      
          Private Sub ClearSaleButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearSaleButton.Click
              'Clear previous amount from the form
      
              titleTextBox.Clear()
              PriceTextBox.Clear()
              ExtendedPriceTextBox.Clear()
              DiscountedTextBox.Clear()
              With QuantityTextBox
                  .Clear()
                  .Focus()
              End With
          End Sub
      Last edited by Frinavale; Apr 14 '10, 01:26 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Shanehenery,

        When you have a new question please post it in a new thread. Do not ask a new question in a thread that has already been answered and is not relevant to the new question. I have split this question off of your other thread:VB.NET installation problem.

        I do not know what you are having problems with here. Are you just trying to add an R in front of the discounted value displayed in the TextBox?

        In that case do so on line 38, 39 or 40 (which ever is the one that is supposed to have an R in front of it)

        -Frinny

        Comment

        • shanehenery
          New Member
          • Feb 2010
          • 24

          #5
          Hi

          can you tell me how do I change the currency from dollar to rand
          in a TextBox
          it needs to calculate in rands and add the R symbol in front of the calculation
          ex: R1.00

          Thanks

          Comment

          • Frinavale
            Recognized Expert Expert
            • Oct 2006
            • 9749

            #6
            What is rand?

            Comment

            • shanehenery
              New Member
              • Feb 2010
              • 24

              #7
              Hi

              it is South African rands it is the currancy that South Africa use
              the simbol is a "R"

              Comment

              • Frinavale
                Recognized Expert Expert
                • Oct 2006
                • 9749

                #8
                Well the first thing you should do is look up the Exchange rate and then use that rate to calculate the amount in South African Rand.

                Comment

                Working...