07-15-2014, 01:35 PM
(This post was last modified: 07-15-2014, 01:37 PM by kotaramamohana.)
Hi,
i have updated your for loop code, it is working now
i have updated your for loop code, it is working now
Code:
Dim num,sum,getdigit
sum=0
getdigit=""
num=Inputbox("Enter a four digit number")
If Len(num) <> 4 Then
Msgbox("Number is not four digit no")
else
For i=0 to Len(num)-1
getdigit=Mid(num,i+1,1)
'MsgBox(getdigit)
sum = sum+cInt(getdigit)
next
MsgBox("Sum of the digits is " & sum)
End if