Hi. I'm having a problem getting the per values or per digits entered in a textbox? and I need to sum it up that shows the answer in another textbox. like for example I've enter 123 in textbox1 and textbox2 should display the answer as 6 which the sum when you add 1+2+3.
Thanks in advance.:?:

Recommended Answers

All 2 Replies

Whatever you enter in a TextBox it is collected as a string.(Using the Text property of the TextBox)
So if you want to do your summation, you have to disect textbox1.Text with the SubString method, and transform the substring obtained to a number by using a Parse method.

Whatever you enter in a TextBox it is collected as a string.(Using the Text property of the TextBox)
So if you want to do your summation, you have to disect textbox1.Text with the SubString method, and transform the substring obtained to a number by using a Parse method.

If you are doing individual characters, there is no reason to use Substring (unless you like making things hard on yourself). String can be treated as character arrays, and you can use the standard array syntax to index each character.

commented: I agree! +7
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.