8 Replies - 1101 Views - Last Post: 25 January 2013 - 12:35 PM Rate Topic: -----

#1 MafiaAndre  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 18-January 13

Multiplying with percentages

Posted 25 January 2013 - 08:17 AM

Hi all.
How can I automatically code my program so that when I type figures in a textbox, it will automatically be multiplied with a certain number and the answer of this multiplication will be in another textbox?

I have no coding yet, I have searched everything, but nothing helps me...

Please Help!!
Is This A Good Question/Topic? 0
  • +

Replies To: Multiplying with percentages

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9093
  • View blog
  • Posts: 34,145
  • Joined: 12-June 08

Re: Multiplying with percentages

Posted 25 January 2013 - 08:19 AM

Events.. you have textbox1.. you can hook up many different events but I would typically just use 'text changed'. So a user enters something in there and leaves focus of the textbox.. the textbox fires the event.. in the event you write the code to grab the text entered.. validate it's a number.. multiply it by what ever.. and put the value in textbox2.

Easy peasy, right?
Was This Post Helpful? 0
  • +
  • -

#3 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 448
  • View blog
  • Posts: 3,103
  • Joined: 12-January 10

Re: Multiplying with percentages

Posted 25 January 2013 - 08:33 AM

just remeber when multiplying to get the % you have have to use actual numbers and not a percent.


meaning

input 100

you want 10%
you cant do 100 x 10%


you have to do 100 x .1

keep that in mind
Was This Post Helpful? 0
  • +
  • -

#4 MafiaAndre  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 18-January 13

Re: Multiplying with percentages

Posted 25 January 2013 - 08:34 AM

View Postmodi123_1, on 25 January 2013 - 08:19 AM, said:

Events.. you have textbox1.. you can hook up many different events but I would typically just use 'text changed'. So a user enters something in there and leaves focus of the textbox.. the textbox fires the event.. in the event you write the code to grab the text entered.. validate it's a number.. multiply it by what ever.. and put the value in textbox2.

Easy peasy, right?


Hi, uhm did you read what I need? I'm kinda asking for help with the coding to do so. I don't know how to code a multiplication... The only coding I got from a site, was to multiply some numbers with another number, but NOT with a percentage.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9093
  • View blog
  • Posts: 34,145
  • Joined: 12-June 08

Re: Multiplying with percentages

Posted 25 January 2013 - 08:47 AM

Quote

Hi, uhm did you read what I need? I'm kinda asking for help with the coding to do so. I

Hi, uhm, did you read the forum rules, FAQ, the giant yellow 'asking a question' box when you made the post, and the water mark in the post box that is telling you we won't do your homework or write the code for you, but... *BUT* will help guide you to write the code yourself? Yeah.. re-read those!

After that buck up and just *TRY* following peeps have said here. I mean what's the worst that can happen? You gain the aplomb to get farther!
Was This Post Helpful? 0
  • +
  • -

#6 torind_2000  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 57
  • View blog
  • Posts: 288
  • Joined: 22-August 11

Re: Multiplying with percentages

Posted 25 January 2013 - 09:17 AM

View PostMafiaAndre, on 25 January 2013 - 10:34 AM, said:

Hi, uhm did you read what I need? I'm kinda asking for help with the coding to do so. I don't know how to code a multiplication... The only coding I got from a site, was to multiply some numbers with another number, but NOT with a percentage.


Examples are good, but they are only examples and will only take you so far. You WILL eventually have to think for yourself.

So you want to multiply with percents? First, do you know how to convert whole numbers into percents on paper?
If you recall from basic math, percents are really fractions. So if you make your numbers like:

   10
 ----
  100



you get a fraction, then you might recall that if you divide the top number by the bottom number to get your percent in decimal form.

which would look like

myPercent = topNum / 100


Now you have the proper number to do the math with.
Next you gotta figure out how to use it.

One way I might do it:

1. Create a variable to store myPercent, myAnswer and whatever else I needed
2. Use TryParse() to convert the input from the textbox to a number
3. Do the math using the variables I've created
4. Use ToString() to convert myAnswer back into a string and display it in a label.

So now we have something of a plan, now we could bang out some code and see if it works.
If it doesn't we would use some debugging skills and try to fix it.
Was This Post Helpful? 0
  • +
  • -

#7 MafiaAndre  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 18-January 13

Re: Multiplying with percentages

Posted 25 January 2013 - 10:36 AM

View Posttorind_2000, on 25 January 2013 - 09:17 AM, said:

View PostMafiaAndre, on 25 January 2013 - 10:34 AM, said:

Hi, uhm did you read what I need? I'm kinda asking for help with the coding to do so. I don't know how to code a multiplication... The only coding I got from a site, was to multiply some numbers with another number, but NOT with a percentage.


Examples are good, but they are only examples and will only take you so far. You WILL eventually have to think for yourself.

So you want to multiply with percents? First, do you know how to convert whole numbers into percents on paper?
If you recall from basic math, percents are really fractions. So if you make your numbers like:

   10
 ----
  100



you get a fraction, then you might recall that if you divide the top number by the bottom number to get your percent in decimal form.

which would look like

myPercent = topNum / 100


Now you have the proper number to do the math with.
Next you gotta figure out how to use it.

One way I might do it:

1. Create a variable to store myPercent, myAnswer and whatever else I needed
2. Use TryParse() to convert the input from the textbox to a number
3. Do the math using the variables I've created
4. Use ToString() to convert myAnswer back into a string and display it in a label.

So now we have something of a plan, now we could bang out some code and see if it works.
If it doesn't we would use some debugging skills and try to fix it.


I am not sure what to do. This is not doing my project for me or doing my homework. I'm developing this program for myself to use when doing TAX. I just need the basic coding, or an example, and I'll figure out how to use the sample coding in my project. Please?
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9093
  • View blog
  • Posts: 34,145
  • Joined: 12-June 08

Re: Multiplying with percentages

Posted 25 January 2013 - 10:41 AM

Quote

I just need the basic coding, or an example, and I'll figure out how to use the sample coding in my project. Please?

Really? Let's take a few large steps backwards. How would you code up two variables multiplying against each other and storing in a third variable? You know a classic "a * b = c".
Was This Post Helpful? 0
  • +
  • -

#9 torind_2000  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 57
  • View blog
  • Posts: 288
  • Joined: 22-August 11

Re: Multiplying with percentages

Posted 25 January 2013 - 12:35 PM

View PostMafiaAndre, on 25 January 2013 - 12:36 PM, said:

I am not sure what to do. This is not doing my project for me or doing my homework. I'm developing this program for myself to use when doing TAX. I just need the basic coding, or an example, and I'll figure out how to use the sample coding in my project. Please?


Sure, I charge $100 dollars an hour, plus tax, with a 2 hour minimum. I accept Paypal, Visa, Mastercard, Discover, and Amex.

Or you could buy buy a book, like this one and learn this basic stuff yourself for way cheaper. Not to mention the satisfaction you'd get by learning something new then applying those skills to make your very own tax calculator.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1