Twenty years ago I built the following Function.
Function SUMDIGITS(MyString As String) As Long
Dim MyLen As Long
Dim MyAnswer As Long
Dim i As Integer
MyAnswer = 0
MyLen = Len(MyString)
For i = 1 To MyLen
If IsNumeric(Mid(MyString, i, 1)) Then
MyAnswer = MyAnswer + CInt(Mid(MyString, i, 1))
End If
Next
SUMDIGITS = MyAnswer
End Function
It is gives strange answers. For example applying this function to the string
// ref1 & ref2 may be 6- or 8-digit references eg SU387148 or SU38714856
Generates the answer 90, which is the sum of each individual digit in the string.
Can anyone identify a good reason for keeping the Function as it stands?
Bookmarks