-2
有人知道我怎麼能在訪問應用拉恩算法,用於與電話號碼驗證的參考號應用Lunh算法訪問
有人知道我怎麼能在訪問應用拉恩算法,用於與電話號碼驗證的參考號應用Lunh算法訪問
該函數將計算校驗位爲您提供:
Public Function Modulus1x(ByVal strNum As String, ByVal intModulus As Integer) As Integer
' Creates the Modulus-10 or -11 check digit for strNum.
' Non-numeric characters are ignored.
' Maximum length of number.
Const cintNumLenMax = 31
Dim strTmp As String
Dim intChr As Integer
Dim intLen As Integer
Dim intSum As Integer
Dim intVal As Integer
Dim intWeight As Integer
Dim intCount As Integer
Dim intChk As Integer
Select Case intModulus
Case 10, 11
intLen = Len(strNum)
If intLen > 0 Then
' Remove non-numeric characters.
For intCount = 1 To intLen
intChr = Asc(Mid(strNum, intCount))
If intChr >= 48 And intChr <= 57 Then
strTmp = strTmp & Chr(intChr)
End If
Next intCount
strNum = strTmp
intLen = Len(strNum)
If intLen > 0 Then
' Calculate check digit.
If intLen <= cintNumLenMax Then
For intCount = 1 To intLen
intVal = Val(Mid(strNum, intLen - intCount + 1, 1))
Select Case intModulus
Case 10
intWeight = 1 + (intCount Mod 2)
intVal = intWeight * intVal
intVal = Int(intVal/10) + (intVal Mod 10)
Case 11
intWeight = 2 + ((intCount - 1) Mod 6)
intVal = intWeight * intVal
End Select
intSum = intSum + intVal
Next intCount
intChk = -Int(-intSum/intModulus) * intModulus - intSum
End If
End If
End If
End Select
Modulus1x = intChk
End Function
只是通過電話號碼:
PhoneNumber = ""
CheckDigit = Modulus1x(PhoneNumber, 10)
PhoneNumberWithCheckDigit = PhoneNumber & CheckDigit
並與這裏的功能:Modulus Check
你可以驗證PhoneNumberWithCheckDigit
非常感謝。你是最棒的 –
我需要的盧恩算法插入「參考號」字段,以便它生成的校驗位爲我們的BPAŸ客戶,他們不能讓P AŸ換貨不正確的校驗數。 支票號碼是從客戶的'電話號碼'生成的。 –
我找到了這段代碼。 http://www.tek-tips.com/faqs.cfm?fid=6704但我不確定如何使用電話號碼 –