locked
Totaal RRS feed

  • Question

  • Hi

    how can a textbox get the total of all entered numbers in other textbox?

    what I have gets the number + the entered number like:

      1 entered, 2 entered, 3 entered

    en the total will be 123, but what I want is "6 "witch is"= 1+2+3"

    Friday, November 1, 2013 11:48 AM

Answers

  • Hi,

    (1)Initialise string variable & store value of Entered Number of First Text Box

    (2)Using Subtring function, isolate each digit 

    (3)Do the sum by any arithmetic function

    (4)Show the sum in Second Text Box

    Thanks,

    Himanshu 


    Himanshu Mehta

    Friday, November 1, 2013 12:40 PM

All replies

  • Hi,

    (1)Initialise string variable & store value of Entered Number of First Text Box

    (2)Using Subtring function, isolate each digit 

    (3)Do the sum by any arithmetic function

    (4)Show the sum in Second Text Box

    Thanks,

    Himanshu 


    Himanshu Mehta

    Friday, November 1, 2013 12:40 PM
  • thanx
     :)

    • Edited by shawnem Friday, November 1, 2013 1:23 PM
    Friday, November 1, 2013 1:22 PM
  • Try this logic. it may work.

    string s1 = Editbox.Text;

    int total = 0;

    for (int i =0; i < s1.length ; i++)

    {   total = total + Convert.ToInt32(s1[i]);

    }

    Console.Writeline ("Total is .. " + total);

    Saturday, November 2, 2013 5:13 PM