英文:
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)
'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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论