Sum Integer Values [modified]
-
Hi all, I need to make function that recieve any number from textbox and return the sum of this number without convert this number to string to dealing with it's index and get the sum, So the Number 2543 will return 14 So My Question is : what's the other way to Get Sum of number without converting to string, Bytheway the function will recieve integer and return integer. Regards Mr.Wonderful
modified on Tuesday, June 3, 2008 10:18 AM
-
Hi all, I need to make function that recieve any number from textbox and return the sum of this number without convert this number to string to dealing with it's index and get the sum, So the Number 2543 will return 14 So My Question is : what's the other way to Get Sum of number without converting to string, Bytheway the function will recieve integer and return integer. Regards Mr.Wonderful
modified on Tuesday, June 3, 2008 10:18 AM
Mr. Wonderful wrote:
I need to make function that recieve any number from textbox and return the sum of this number without convert this number to string to dealing with it's index and get the sum, So the Number 2543 will return 11
That makes no sense. If the number is coming from a test box then it already is a string.
Recent blog posts: * Introduction to LINQ to XML (Part 1) - (Part 2) - (part 3) My website | Blog
-
Mr. Wonderful wrote:
I need to make function that recieve any number from textbox and return the sum of this number without convert this number to string to dealing with it's index and get the sum, So the Number 2543 will return 11
That makes no sense. If the number is coming from a test box then it already is a string.
Recent blog posts: * Introduction to LINQ to XML (Part 1) - (Part 2) - (part 3) My website | Blog
Ok, No Problem.. Suppose there is no textbox and you fill the function manually, thats mean you write the number direct to the function, How the Solution Could Be.
-
Ok, No Problem.. Suppose there is no textbox and you fill the function manually, thats mean you write the number direct to the function, How the Solution Could Be.
Mr. Wonderful wrote:
Ok, No Problem.. Suppose there is no textbox and you fill the function manually, thats mean you write the number direct to the function, How the Solution Could Be.
To begin with, in your OP you stated the number coming from input field. As colin pointed out you will need to address that issue first. If you want to add add the digits of all numbers then you can use mod and divide to dissect each digit and get the sum of each. Here is an example.
Yusuf
modified on Wednesday, June 4, 2008 9:21 AM
-
Mr. Wonderful wrote:
Ok, No Problem.. Suppose there is no textbox and you fill the function manually, thats mean you write the number direct to the function, How the Solution Could Be.
To begin with, in your OP you stated the number coming from input field. As colin pointed out you will need to address that issue first. If you want to add add the digits of all numbers then you can use mod and divide to dissect each digit and get the sum of each. Here is an example.
Yusuf
modified on Wednesday, June 4, 2008 9:21 AM
Thanks a lot it was very Useful Site. Mr.Wonderful