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

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

Take 10 numbers from the right to calculate a key

问题

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

  1. Public Function CCP(Cle_CCP As String) As String
  2. CCP = Len(Cle_CCP)
  3. CCP = (10 - CCP)
  4. For i = 1 To CCP
  5. M = M & "0"
  6. Next
  7. CCP = M & Cle_CCP
  8. M1 = Mid(CCP, 1, 1) * 13
  9. M2 = Mid(CCP, 2, 1) * 12
  10. M3 = Mid(CCP, 3, 1) * 11
  11. M4 = Mid(CCP, 4, 1) * 10
  12. M5 = Mid(CCP, 5, 1) * 9
  13. M6 = Mid(CCP, 6, 1) * 8
  14. M7 = Mid(CCP, 7, 1) * 7
  15. M8 = Mid(CCP, 8, 1) * 6
  16. M9 = Mid(CCP, 9, 1) * 5
  17. M10 = Mid(CCP, 10, 1) * 4
  18. CCP = M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10
  19. If CCP < 10 Then
  20. CCP = "0" & CCP
  21. Else
  22. CCP = CCP
  23. End If
  24. CCP = Right(CCP, 2)
  25. End Function
  26. '''''''''''''''''''''''''''''
  27. Public Function RIP(Cle_RIP As String) As String
  28. If Cle_RIP = "" Then
  29. Cle_RIP = 0
  30. End If
  31. RIP = Cle_RIP * 100
  32. RIP = RIP - 97 * Int(RIP / 97)
  33. RIP = RIP + 85
  34. If RIP < 97 Then
  35. RIP = RIP + 97
  36. Else
  37. RIP = RIP
  38. End If
  39. RIP = RIP - 97
  40. RIP = 97 - RIP
  41. If RIP < 10 Then
  42. RIP = "0" & RIP
  43. Else
  44. RIP = RIP
  45. End If
  46. 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 :

  1. Public Function CCP(Cle_CCP As String) As String
  2. CCP = Len(Cle_CCP)
  3. CCP = (10 - CCP)
  4. For i = 1 To CCP
  5. M = M & "0"
  6. Next
  7. CCP = M & Cle_CCP
  8. M1 = Mid(CCP, 1, 1) * 13
  9. M2 = Mid(CCP, 2, 1) * 12
  10. M3 = Mid(CCP, 3, 1) * 11
  11. M4 = Mid(CCP, 4, 1) * 10
  12. M5 = Mid(CCP, 5, 1) * 9
  13. M6 = Mid(CCP, 6, 1) * 8
  14. M7 = Mid(CCP, 7, 1) * 7
  15. M8 = Mid(CCP, 8, 1) * 6
  16. M9 = Mid(CCP, 9, 1) * 5
  17. M10 = Mid(CCP, 10, 1) * 4
  18. CCP = M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10
  19. If CCP < 10 Then
  20. CCP = "0" & CCP
  21. Else
  22. CCP = CCP
  23. End If
  24. CCP = Right(CCP, 2)
  25. End Function
  26. '''''''''''''''''''''''''''''
  27. Public Function RIP(Cle_RIP As String) As String
  28. If Cle_RIP = "" Then
  29. Cle_RIP = 0
  30. End If
  31. RIP = Cle_RIP * 100
  32. RIP = RIP - 97 * Int(RIP / 97)
  33. RIP = RIP + 85
  34. If RIP < 97 Then
  35. RIP = RIP + 97
  36. Else
  37. RIP = RIP
  38. End If
  39. RIP = RIP - 97
  40. RIP = 97 - RIP
  41. If RIP < 10 Then
  42. RIP = "0" & RIP
  43. Else
  44. RIP = RIP
  45. End If
  46. End Function

答案1

得分: 1

请尝试以下代码:

  1. Public Function CCP(Cle_CCP As String) As String
  2. CCP = Len(Cle_CCP)
  3. CCP = (10 - CCP)
  4. 'For i = 1 To CCP
  5. 'M = M & "0"
  6. 'Next
  7. CCP = Right("0000000000" & Cle_CCP, 10)
  8. M1 = Mid(CCP, 1, 1) * 13
  9. M2 = Mid(CCP, 2, 1) * 12
  10. M3 = Mid(CCP, 3, 1) * 11
  11. M4 = Mid(CCP, 4, 1) * 10
  12. M5 = Mid(CCP, 5, 1) * 9
  13. M6 = Mid(CCP, 6, 1) * 8
  14. M7 = Mid(CCP, 7, 1) * 7
  15. M8 = Mid(CCP, 8, 1) * 6
  16. M9 = Mid(CCP, 9, 1) * 5
  17. M10 = Mid(CCP, 10, 1) * 4
  18. CCP = M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10
  19. If CCP < 10 Then
  20. CCP = "0" & CCP
  21. Else
  22. CCP = CCP
  23. End If
  24. CCP = Right(CCP, 2)
  25. End Function
英文:

Would you please give a try to the following codes-

  1. Public Function CCP(Cle_CCP As String) As String
  2. CCP = Len(Cle_CCP)
  3. CCP = (10 - CCP)
  4. &#39;For i = 1 To CCP
  5. &#39;M = M &amp; &quot;0&quot;
  6. &#39;Next
  7. CCP = Right(&quot;0000000000&quot; &amp; Cle_CCP, 10)
  8. M1 = Mid(CCP, 1, 1) * 13
  9. M2 = Mid(CCP, 2, 1) * 12
  10. M3 = Mid(CCP, 3, 1) * 11
  11. M4 = Mid(CCP, 4, 1) * 10
  12. M5 = Mid(CCP, 5, 1) * 9
  13. M6 = Mid(CCP, 6, 1) * 8
  14. M7 = Mid(CCP, 7, 1) * 7
  15. M8 = Mid(CCP, 8, 1) * 6
  16. M9 = Mid(CCP, 9, 1) * 5
  17. M10 = Mid(CCP, 10, 1) * 4
  18. CCP = M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10
  19. If CCP &lt; 10 Then
  20. CCP = &quot;0&quot; &amp; CCP
  21. Else
  22. CCP = CCP
  23. End If
  24. CCP = Right(CCP, 2)
  25. 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:

确定