Today by 9.30pm one of my friend called me and asked a small, a very small question “Machan, how to get the sum of digits in a given number in VB”. This was a simpler question to understand but this has a trick, a simple math trick. After 30 mins of code work I got the simple solution. The main problem I faced was <> operator and commenting in VB because It has been almost 2 years that I finally coded in VB.net

Finally this was my code

    Private Sub button1_clicked(sender As Object, e As EventArgs) Handles Button1.Click
        Dim num, n, r As Integer
        num = 0
        n = Int(TextBox1.Text)
        While n <> 0
            r = n Mod 10
            num += r
            n = 10
        End While
    End Sub