The most likely cause of this is that the data you are passing in the
strInput argument includes one or more non-numeric characters. For example,
if your customer number looked something like "ABC123", you'd need to strip
off the "ABC" portion and pass only the "123" part to the function.
Similarly if your customer number includes any spaces, punctuation or such,
you'll need to strip them out first. If you want the function to handle that
for you, you could modify it something like so ...
Public Function CalcCheckDigit(ByVal strInput As String) As String
'Betalingsident.: 0 2 6 8 4 0 1 4 9 9 6 5 3 2
'Vægttal: 1 2 1 2 1 2 1 2 1 2 1 2 1 2
'Summer: 0 4 6 16 4 0 1 8 9 18 6 10 3 4
'Tæller: 0 +4 +6 +7 +4 +0 +1 +8 +9 +9 +6 +1 +3 +4=62
'Tæller/modulus 62/10 = rest = 2
'Kontrolciffer 10 - 2 = 8
Dim strWork As String
Dim strChar As String
Dim alngWork() As Long
Dim lngLoop As Long
Dim lngMultiplier As Long
Dim lngResult As Long
For lngLoop = 1 To Len(strInput)
strChar = Mid$(strInput, lngLoop, 1)
If Asc(strChar) >= Asc("0") And Asc(strChar) <= Asc("9") Then
strWork = strWork & strChar
End If
Next lngLoop
ReDim alngWork(0 To Len(strWork) - 1)
For lngLoop = 1 To Len(strWork)
alngWork(lngLoop - 1) = CLng(Mid$(strWork, lngLoop, 1))
Next lngLoop
For lngLoop = LBound(alngWork) To UBound(alngWork)
If (lngLoop + 1) Mod 2 Then
lngMultiplier = 1
Else
lngMultiplier = 2
End If
alngWork(lngLoop) = alngWork(lngLoop) * lngMultiplier
Next lngLoop
For lngLoop = LBound(alngWork) To UBound(alngWork)
lngResult = lngResult + ((alngWork(lngLoop) \ 10) +
(alngWork(lngLoop) Mod 10))
Next lngLoop
lngResult = 10 - (lngResult Mod 10)
CalcCheckDigit = lngResult
End Function