VBSlip2_1_2015-16



=================================Slip 2_1=================================
Write a VB Program to find sum of digit of a given number till it reduces to single digit.  Accept input through textbox and Display the output in Message Box (using function)                           ========================================================================








Private Sub Command1_Click()

                ans = display()
                MsgBox ("Ansis "&ans)
End Sub
Public Function display() As Integer
                s = 0
                n = Val(Text1.Text)
                While n > 9
                                s = 0
                                While n > 0
                                                r = n Mod 10
                                                s = s + r
                                                n = n \ 10
                                Wend
                                n = s
                Wend
                display = s
End Function
 

No comments:

Post a Comment

Note: only a member of this blog may post a comment.