473,394 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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
Apr 14 '10 #1
7 2861
MrMancunian
569 Expert 512MB
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
Apr 14 '10 #2
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
Expand|Select|Wrap|Line Numbers
  1. 'Calculate the price and discount
  2.  
  3.         Dim QuantityInteger As Integer
  4.         Dim PriceDecimal, ExtendedPriceDecimal, DiscountDecimal, DiscountedPriceDecimal, AverageDiscountDecimal, _
  5.          DISCOUNT_RATE_Decimal, ExtendedPriceDecilmal, QuantitySumInteger, DiscountSumDecimal, SaleCountInteger, _
  6.            DiscountedSumDecimal, AverageDescountDecimal As Decimal
  7.         Try
  8.             'Convert quantity to numeric variable
  9.             QuantityInteger = Integer.Parse(QuantityTextBox.Text)
  10.         Catch ex As Exception
  11.         End Try
  12.  
  13.         Try
  14.             'Convertprice if quantity was successful.
  15.  
  16.             PriceDecimal = Decimal.Parse(PriceTextBox.Text)
  17.             'Calculate values for sale.
  18.             ExtendedPriceDecimal = QuantityInteger * PriceDecimal
  19.             DiscountDecimal = Decimal.Round( _
  20.             (ExtendedPriceDecimal * DISCOUNT_RATE_Decimal), 1)
  21.             DiscountedPriceDecimal = ExtendedPriceDecilmal - DiscountDecimal
  22.  
  23.  
  24.             'Calculate summary values.
  25.             QuantitySumInteger += QuantityInteger
  26.             DiscountSumDecimal += DiscountDecimal
  27.             SaleCountInteger += 1
  28.             AverageDiscountDecimal = DiscountSumDecimal / SaleCountInteger
  29.  
  30.  
  31.             'Format and display answer for the sale
  32.             ExtendedPriceTextBox.Text = ExtendedPriceDecimal.ToString("C")
  33.             DiscountTextBox.Text = DiscountDecimal.ToString("N")
  34.             DiscountedTextBox.Text = DiscountedPriceDecimal.ToString("C")
  35.  
  36.             'Format and display summary values.
  37.  
  38.             QuantitySumTextBox.Text = QuantitySumInteger.ToString()
  39.             DiscountTextBox.Text = DiscountedSumDecimal.ToString("C")
  40.             AverageDiscountTextBox.Text = AverageDescountDecimal.ToString("C")
  41.  
  42.  
  43.         Catch PriceException As FormatException
  44.             'Handle a price exception
  45.             MessageBox.Show("Price must be numeric.", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  46.             With PriceTextBox
  47.                 .Focus()
  48.                 .SelectAll()
  49.             End With
  50.         End Try
  51.         Try
  52.         Catch QuantityException As FormatException
  53.             'Handle a quantity  exception.
  54.             MessageBox.Show("Quantity must be numeric. ", "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  55.             With QuantityTextBox
  56.                 .Focus()
  57.                 .SelectAll()
  58.             End With
  59.         End Try
  60.  
  61.     End Sub
  62.  
  63.     Private Sub RnR_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  64.  
  65.     End Sub
  66.  
  67.     Private Sub ClearSaleButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearSaleButton.Click
  68.         'Clear previous amount from the form
  69.  
  70.         titleTextBox.Clear()
  71.         PriceTextBox.Clear()
  72.         ExtendedPriceTextBox.Clear()
  73.         DiscountedTextBox.Clear()
  74.         With QuantityTextBox
  75.             .Clear()
  76.             .Focus()
  77.         End With
  78.     End Sub
Apr 14 '10 #3
Frinavale
9,735 Expert Mod 8TB
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
Apr 14 '10 #4
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
Apr 14 '10 #5
Frinavale
9,735 Expert Mod 8TB
What is rand?
Apr 14 '10 #6
Hi

it is South African rands it is the currancy that South Africa use
the simbol is a "R"
Apr 14 '10 #7
Frinavale
9,735 Expert Mod 8TB
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.
Apr 14 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Phil Powell | last post by:
Relevancy scores are normally defined by a MySQL query on a table that has a fulltext index. The rules for relevancy scoring will exclude certain words due to their being too short (minimum...
1
by: Building Blocks | last post by:
Hi, All I need is a simle calculate form script which contains this: A script that can handle text input, radio buttons, checkboxes, and dropdowns. Each one of these variables will contain a...
4
by: Jan Szymczuk | last post by:
I'm creating an MS Access 2000 database where I have a number of people entered using simple basic fields, Surname: SMITH Forenames: John DoB: 09/09/1958 Age:...
1
by: evilasukakitty | last post by:
I too am new to the whole C++ language, and I am an eager beaver and wish I could absorb it all instantly, but I can't. The first program I wrote (very simple) was easy enough, using your basic cin...
3
by: Libber39 | last post by:
Hi everyone, Have a query on how to calculate the amount of weeks and days contained in a number in an access query. ie: the difference in days between 2 dates amounts to 17 days. I want to now...
3
by: gator6688 | last post by:
I have to write a program that asks for a cost-per-item, number of items purchased, and a discount rate. Then it should calculate the total cost, tax due, and amount due. I have to use the...
5
by: zivon | last post by:
Hello everyone ! I made a price calculator for a guest house. I have diffrent sale campaigns, all the time, I made a table with campaign name and discount, for example: name "pensioners"...
0
by: SuzK | last post by:
I am trying to calculate in VBA in Access 2002 a moving average and update a table with the calculations. Fields in my WeeklyData table are Week Ending (date) ItemNbr (double) Sales Dollars...
6
by: rrstudio2 | last post by:
I am using the following vba code to calculate the median of a table in MS Access: Public Function MedianOfRst(RstName As String, fldName As String) As Double 'This function will calculate the...
3
by: pradeep c | last post by:
can any one tell me how to instal the software component in discount asp.net.. pleas its urgent it will be very helpful for me.
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.