取右侧的10个数字来计算一个密钥。

huangapple go评论82阅读模式
英文:

Take 10 numbers from the right to calculate a key

问题

以下是您要翻译的代码部分:

Public Function CCP(Cle_CCP As String) As String

CCP = Len(Cle_CCP)
CCP = (10 - CCP)
For i = 1 To CCP
M = M & "0"
Next
CCP = M & Cle_CCP
M1 = Mid(CCP, 1, 1) * 13
M2 = Mid(CCP, 2, 1) * 12
M3 = Mid(CCP, 3, 1) * 11
M4 = Mid(CCP, 4, 1) * 10
M5 = Mid(CCP, 5, 1) * 9
M6 = Mid(CCP, 6, 1) * 8
M7 = Mid(CCP, 7, 1) * 7
M8 = Mid(CCP, 8, 1) * 6
M9 = Mid(CCP, 9, 1) * 5
M10 = Mid(CCP, 10, 1) * 4
CCP = M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10

If CCP < 10 Then
   CCP = "0" & CCP
Else
   CCP = CCP
End If

CCP = Right(CCP, 2)

End Function

'''''''''''''''''''''''''''''

Public Function RIP(Cle_RIP As String) As String

If Cle_RIP = "" Then
   Cle_RIP = 0
End If

RIP = Cle_RIP * 100
RIP = RIP - 97 * Int(RIP / 97)
RIP = RIP + 85

If RIP < 97 Then
   RIP = RIP + 97
Else
   RIP = RIP
End If

RIP = RIP - 97
RIP = 97 - RIP

If RIP < 10 Then
   RIP = "0" & RIP
Else
   RIP = RIP
End If
End Function

请注意,我只提供了代码的翻译部分,不包括问题或其他内容。如果您需要进一步的解释或有其他问题,请随时提出。

英文:

I have these two codes, they calculate the keys of a bank account number, by I want to modify them so that the code would take 10 numbers from the right to calculate the corresponding key.
For example if the number is : 6465981, the code will take it all into consideration since it’s 7 numbers long.
If the number is 007999990006465981, it will take 0006465981 to calculate the key.
The two codes are :

Public Function CCP(Cle_CCP As String) As String
CCP = Len(Cle_CCP)
CCP = (10 - CCP)
For i = 1 To CCP
M = M & "0"
Next
CCP = M & Cle_CCP
M1 = Mid(CCP, 1, 1) * 13
M2 = Mid(CCP, 2, 1) * 12
M3 = Mid(CCP, 3, 1) * 11
M4 = Mid(CCP, 4, 1) * 10
M5 = Mid(CCP, 5, 1) * 9
M6 = Mid(CCP, 6, 1) * 8
M7 = Mid(CCP, 7, 1) * 7
M8 = Mid(CCP, 8, 1) * 6
M9 = Mid(CCP, 9, 1) * 5
M10 = Mid(CCP, 10, 1) * 4
CCP = M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10
If CCP < 10 Then
CCP = "0" & CCP
Else
CCP = CCP
End If
CCP = Right(CCP, 2)
End Function
'''''''''''''''''''''''''''''
Public Function RIP(Cle_RIP As String) As String
If Cle_RIP = "" Then
Cle_RIP = 0
End If
RIP = Cle_RIP * 100
RIP = RIP - 97 * Int(RIP / 97)
RIP = RIP + 85
If RIP < 97 Then
RIP = RIP + 97
Else
RIP = RIP
End If
RIP = RIP - 97
RIP = 97 - RIP
If RIP < 10 Then
RIP = "0" & RIP
Else
RIP = RIP
End If
End Function

答案1

得分: 1

请尝试以下代码:

Public Function CCP(Cle_CCP As String) As String

    CCP = Len(Cle_CCP)
    CCP = (10 - CCP)

    'For i = 1 To CCP
    'M = M & "0"
    'Next

    CCP = Right("0000000000" & Cle_CCP, 10)
    M1 = Mid(CCP, 1, 1) * 13
    M2 = Mid(CCP, 2, 1) * 12
    M3 = Mid(CCP, 3, 1) * 11
    M4 = Mid(CCP, 4, 1) * 10
    M5 = Mid(CCP, 5, 1) * 9
    M6 = Mid(CCP, 6, 1) * 8
    M7 = Mid(CCP, 7, 1) * 7
    M8 = Mid(CCP, 8, 1) * 6
    M9 = Mid(CCP, 9, 1) * 5
    M10 = Mid(CCP, 10, 1) * 4
    CCP = M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10

    If CCP < 10 Then
       CCP = "0" & CCP
    Else
       CCP = CCP
    End If

    CCP = Right(CCP, 2)

End Function
英文:

Would you please give a try to the following codes-

Public Function CCP(Cle_CCP As String) As String
CCP = Len(Cle_CCP)
CCP = (10 - CCP)
&#39;For i = 1 To CCP
&#39;M = M &amp; &quot;0&quot;
&#39;Next
CCP = Right(&quot;0000000000&quot; &amp; Cle_CCP, 10)
M1 = Mid(CCP, 1, 1) * 13
M2 = Mid(CCP, 2, 1) * 12
M3 = Mid(CCP, 3, 1) * 11
M4 = Mid(CCP, 4, 1) * 10
M5 = Mid(CCP, 5, 1) * 9
M6 = Mid(CCP, 6, 1) * 8
M7 = Mid(CCP, 7, 1) * 7
M8 = Mid(CCP, 8, 1) * 6
M9 = Mid(CCP, 9, 1) * 5
M10 = Mid(CCP, 10, 1) * 4
CCP = M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10
If CCP &lt; 10 Then
CCP = &quot;0&quot; &amp; CCP
Else
CCP = CCP
End If
CCP = Right(CCP, 2)
End Function

huangapple
  • 本文由 发表于 2023年8月10日 16:26:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76873909.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定