Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > Visual Studio 2005
|
Visual Studio 2005 For discussing Visual Studio 2005. Please post code questions about a specific language (C#, VB, ASP.NET, etc) in the correct language forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Studio 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 18th, 2010, 11:17 PM
Registered User
 
Join Date: Feb 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to andersonlin
Exclamation How can i coded the discount formula?

I'm new to VS.net 2005.here is a problem when i code the discount formula:
Code:
Dim sinPrice As Single, sinDiscount As Single, sinTotal As Single
        Dim intNumber As Integer

        sinPrice = Val(txtPrice.Text)
        sinDiscount = Val(txtDiscount.Text)
        intNumber = Val(txtNumber.Text)

        sinTotal = (sinPrice * intNumber) * sinDiscount * 100%
        txtTotal.Text = sinTotal
how can i calculate the discount formula?
TKS~~~~
 
Old February 19th, 2010, 01:19 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

For example, if you input
price = 500
discount = 10 (this is value or percantage?)
number=2
What is the expected output ?
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
 
Old February 19th, 2010, 08:12 AM
Registered User
 
Join Date: Feb 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to andersonlin
Default Added to the discount formula

here is the question:
make a project,when user input the discount(Number not Percentage),then input the price & amount,calculate the total.retain 3 decimal.
so,is input the Number in discount,and output the total.i don't know how to descrip in VB.
 
Old February 19th, 2010, 09:54 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Code:
sinPrice = Val(txtPrice.Text)
sinDiscount = Val(txtDiscount.Text)
intNumber = Val(txtNumber.Text)

'This will give you the total excluding discount
sinTotal = (sinPrice - sinDiscount) * intNumber
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
 
Old February 19th, 2010, 10:57 PM
Registered User
 
Join Date: Feb 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to andersonlin
Default Thanks for your help

but Om_prakash,the result still not correct.
anyone else?
 
Old February 20th, 2010, 06:34 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

I am still not clear on what output you want...

Please tell me what should be the total value for below case:

Discount: 5
price: 200
Amount: 20
__________________
Om Prakash Pant
Click the "Thanks" button if this post helped you.
 
Old February 20th, 2010, 10:13 AM
Registered User
 
Join Date: Feb 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to andersonlin
Default

Quote:
Originally Posted by om_prakash View Post
I am still not clear on what output you want...

Please tell me what should be the total value for below case:

Discount: 5
price: 200
Amount: 20
The total value should be 2000.
my calculate is wrong since the beginning:
Code:
sinTotal = (sinPrice * intNumber) * sinDiscount
but if use your formula,it still not correct:
Code:
sinTotal = (sinPrice - sinDiscount) * intNumber
for example:
Code:
sinPrice = 100    200      300
sinDiscount = 9           5         8.5
intNumber = 10           10       10
the correct result is sinTotal = 900 1000 255
use your formula the sinTotal = 910 1950 2915
only price can be discounted,i can't find out how to coding the total formula after discount in VB.i only need a formula to calculate the total value after discount,and the discount is a textbox wait for user to input numbers,it changes.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Applying discount blkskullwork Javascript 1 January 11th, 2007 05:14 PM
Discount For P2P Members? anand_thakur Forum and Wrox.com Feedback 0 January 28th, 2005 09:05 AM
mysql discount table hosefo81 PHP Databases 0 December 12th, 2003 10:58 PM
Discount dannomite Wrox Book Feedback 3 June 5th, 2003 10:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.