Option Explicit

 

Private Sub cmdCalc_Click()

    Dim n As Long, alg As Integer, s As Integer

    n = Abs(Val(txtNum.Text))

    Do Until n = 0

        alg = n Mod 10

        s = s + alg

        n = n \ 10

    Loop

    txtResto.Text = s Mod 9

End Sub