Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
 Home Search Members Calendar Who's On
Welcome Guest ( Login | Register )
 Recent PostsRecent Posts Popular TopicsPopular Topics

 Home » .NET Programming » Visual Basic .NET » percentage calculations

 percentage calculations Rate Topic Display Mode Topic Options
Author
 Message
 zeusgeckozeusgecko
 Posted 3/15/2005 11:00:29 PM
 Forum NewbieGroup: Forum MembersLast Login: 3/16/2005 10:25:00 PMPosts: 1, Visits: 1
 Can anyone please tell me how to calculate for percentages? What I'm trying to do is calculate a mortgage payment. The first text box is for the purchase price, the second is for the interest rate...then submit and the payment comes up...it works, it's just that I have to put .6 for 6% and that's not right...that's 60%. when I put in .06, it's not putting the decimal in the right spot...the code looks like this:If IsPostBack Thenlblpayments.text = "your monthly payments will be \$"lblpayments.text += Cstr(txtprice.text * txtrate.text / 100)lblpayments.visible = trueend ifend subCan anyone tell me what is either wrong with this or how to make it calculate percentages? Thanks a million. have a great day.VB.NET in Training
Post #9548
 ShinobiShinobi
 Posted 3/18/2005 10:15:41 AM
 Junior MemberGroup: Forum MembersLast Login: 3/24/2005 8:12:00 AMPosts: 18, Visits: 1
 ok, first off, your gona need to DIM somthing as a double, that way you get the right decimal spot.So just do this.Dim dblAmount as doubledblAmount = txt(what ever).textuse the dlbAmount, not txt(what ever).textthen when you go to calculate you might want to have "Currency" in there if you don't already. But you dont need it. thats so you can have the commas and decimal places where they need to be. If you know how to use it that is.Been Using VB for 3 Years. I know quite a bit.
Post #9654
 « Prev Topic | Next Topic »