Answered by:
Get the discount percent
Question

Lets say we have a product whose actual price is $900, we are offering 10% discount on the product so it will cost $810.
Now I revert the situation, lets say we know that the actual price is $900 and we are selling it for $810, I want to create a formula so my program should tell me how much percent discount we are offering ?
Can somebody help ?
Friday, July 21, 2017 6:43 PM
Answers

Lets say we have a product whose actual price is $900, we are offering 10% discount on the product so it will cost $810.
Now I revert the situation, lets say we know that the actual price is $900 and we are selling it for $810, I want to create a formula so my program should tell me how much percent discount we are offering ?
Can somebody help ?
Hi
Well,
810 divided by 900 times 100 = 90
so, 100  90 = discount rate (10%)
Regards Les, Livingston, Scotland
 Marked as answer by Sid Williams Tuesday, August 1, 2017 6:58 AM
Friday, July 21, 2017 6:54 PM
All replies

Sid,
That is basic math.
810 means 90% of the original price and therefore the math is simple 810/90*100 to get the original price
The rest is so simple that you may do that yourself.
Success
Cor Edited by Cor Ligthert Friday, July 21, 2017 6:55 PM
Friday, July 21, 2017 6:54 PM 
Lets say we have a product whose actual price is $900, we are offering 10% discount on the product so it will cost $810.
Now I revert the situation, lets say we know that the actual price is $900 and we are selling it for $810, I want to create a formula so my program should tell me how much percent discount we are offering ?
Can somebody help ?
Hi
Well,
810 divided by 900 times 100 = 90
so, 100  90 = discount rate (10%)
Regards Les, Livingston, Scotland
 Marked as answer by Sid Williams Tuesday, August 1, 2017 6:58 AM
Friday, July 21, 2017 6:54 PM 
Edit:
900  (900 (x/100)) = 810
 900 (x/100) = 810  900
x/100 = (810  900) / (900)
x = 100 (900  810) / 900
x = 100 (p1  p2) / p1
x = 10
where x is 10 percent.
 Edited by tommytwotrain Friday, July 21, 2017 7:18 PM
Friday, July 21, 2017 6:57 PM 
Lets say we have a product whose actual price is $900, we are offering 10% discount on the product so it will cost $810.
Now I revert the situation, lets say we know that the actual price is $900 and we are selling it for $810, I want to create a formula so my program should tell me how much percent discount we are offering ?
Can somebody help ?
1 (810/900)
That's 0.1 or 10%.
"A problem well stated is a problem half solved.”  Charles F. Kettering
Friday, July 21, 2017 7:28 PM 
Now I revert the situation, lets say we know that the actual price is $900 and we are selling it for $810, I want to create a formula so my program should tell me how much percent discount we are offering ?
Can somebody help ?
Hi Sid,
Do you want to create a simple project that can calculate discounts automatically when you enter actual price and sell price? If yes, you can refer to the code below. You enter actual price in TextBox1, and enter sell price in Textbox2, the label4 show the discount.
If TextBox1.Text = "" Or TextBox2.Text = "" Then MessageBox.Show("Please enter actual and sell price!") Else Dim agio As Double = Val(TextBox1.Text)  Val(TextBox2.Text) Dim discount As Double = Math.Round(agio / Val(TextBox1.Text) * 100, 2) Label4.Text = discount.ToString() + "%" End If
The result is rounded to two decimal places.
Best Regards,
Cherry
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Monday, July 24, 2017 8:15 AM 
.
If TextBox1.Text = "" Or TextBox2.Text = "" Then MessageBox.Show("Please enter actual and sell price!") Else Dim agio As Double = Val(TextBox1.Text)  Val(TextBox2.Text) Dim discount As Double = Math.Round(agio / Val(TextBox1.Text) * 100, 2) Label4.Text = discount.ToString() + "%" End If
Cherry, I don't know if you are ordered to do this by your bosses. It is not impossible as we see the low quality of the forum stability.
Why do you think nobody gave code. All those persons who replied can do that easily. Maybe all a little bit different, but non of them in a mix of typical VBS, VBA, C# and VB6 code style which you show. VB.Net still accept but therefore it is not good code for VB10 to VB15.
They did not give it, because giving fish is not helping. These forums are to teach persons how to fish.
For yourself, this could have been the code in VB15 (VB2017) way created from yours.
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If IsNumeric(TextBox1.Text) OrElse IsNumeric(TextBox2) Then Dim agio = CDec(TextBox1.Text)  CDec(TextBox2.Text) Dim discount = Math.Round(agio / CDec(TextBox1.Text) * 100, 2, MidpointRounding.AwayFromZero) Label1.Text = CStr(discount) & "%" Else MessageBox.Show("Please enter actual and sell price!") End If End Sub End Class
Of course there are persons who will mark your reply as answer, helping to sell Microsoft less and their competitors more and no moderator will make any change to that.
Success
Cor Edited by Cor Ligthert Monday, July 24, 2017 8:57 AM
Monday, July 24, 2017 8:55 AM 
Lets say we have a product whose actual price is $900, we are offering 10% discount on the product so it will cost $810.
Now I revert the situation, lets say we know that the actual price is $900 and we are selling it for $810, I want to create a formula so my program should tell me how much percent discount we are offering ?
Can somebody help ?
How about (actual price  selling price) / actual price  of course you must multiply by 100 to get the percentage.
Wednesday, July 26, 2017 12:42 AM