Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

*I know VB really is for IT but I need help with the logicbehind the coding* Ok,

ID: 3616453 • Letter: #

Question

*I know VB really is for IT but I need help with the logicbehind the coding*
Ok, the project is asking us to take in three numbers in atext box with no space Ex: 123
then your project is to use modular and normal division by 10 to sum the three numbers . Ex 1+2+3=6
well my project is setting the first number in the output boxand the second number is being left out. then it is taking the lastnumber and adding it to the first instead of getting 6 I get14 because 3+1 =4.... and Ideas?
Dim sum1 As Integer    Dim oldNumber AsInteger    Dim sum As Integer = 0    Dim newNumber AsInteger    Dim newNumber2 AsInteger    Dim sum2 As Integer
   oldNumber =CInt(txtIntegers.Text)
   sum = (oldNumber 10)
   newNumber = (oldNumber /10)

   sum1 = (newNumber 10)
   newNumber2 = (newNumber /10)
   sum2 = newNumber2
   sum += sum1 + sum2

   txtOutput.Text =CStr(newNumber)
*I know VB really is for IT but I need help with the logicbehind the coding*
Ok, the project is asking us to take in three numbers in atext box with no space Ex: 123
then your project is to use modular and normal division by 10 to sum the three numbers . Ex 1+2+3=6
well my project is setting the first number in the output boxand the second number is being left out. then it is taking the lastnumber and adding it to the first instead of getting 6 I get14 because 3+1 =4.... and Ideas?
Dim sum1 As Integer    Dim oldNumber AsInteger    Dim sum As Integer = 0    Dim newNumber AsInteger    Dim newNumber2 AsInteger    Dim sum2 As Integer
   oldNumber =CInt(txtIntegers.Text)
   sum = (oldNumber 10)
   newNumber = (oldNumber /10)

   sum1 = (newNumber 10)
   newNumber2 = (newNumber /10)
   sum2 = newNumber2
   sum += sum1 + sum2

   txtOutput.Text =CStr(newNumber)

Explanation / Answer

Dear...

While(oldNumber > 0)
           sum += oldNumber Mod 10
           oldNumber = oldNumber / 10

        End While

Hope this wil help you...