Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

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


percentage calculationsExpand / Collapse
Author
Message
Posted 3/15/2005 11:00:29 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 3/16/2005 10:25:00 PM
Posts: 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 Then

lblpayments.text = "your monthly payments will be $"

lblpayments.text += Cstr(txtprice.text * txtrate.text / 100)

lblpayments.visible = true

end if

end sub

Can 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
Posted 3/18/2005 10:15:41 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 3/24/2005 8:12:00 AM
Posts: 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 double

dblAmount = txt(what ever).text

use the dlbAmount, not txt(what ever).text

then 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 »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod, Mark, Keithuk

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 2:03pm