Option Explicit
Private Sub Form_Load()
MsgBox SommeChiffre(1234)
MsgBox SommeChiffre("1234")
MsgBox SommeChiffre("12test34")
End Sub
' marche avec tout type de numérique:
' Byte, Integer, Long, Double, Décimal, (chaîne mais avec restriction)
Private Function SommeChiffre(nombre As Variant) As Long
Dim N As String
Dim i As Integer
N = nombre
'On place une gestion d'erreur si caractere
On Error Resume Next
For i = 1 To Len(N)
SommeChiffre = SommeChiffre + CInt(Mid(N, i, 1))
Next
On Error GoTo 0
End Function