Hi there guys, hope you can help me . First of all, the CLABE number is just a banking standard like IBAN or Routing numbers. I've been trying to write a code which could lead to retrieving the whole Mexican CLABE number + control digit from just the first 17 digits. This is how the checksum works
The thing is I am not an expert, and I did this mainly by googling so I don't really know where is the mistake here. I think is just about I don't achieve to return the position number in order to obtain the weight factor so that would be the question.
Here it is a CLABE code to test: 03218000011835971 9=(Control digit)
Thanks in advance .
The thing is I am not an expert, and I did this mainly by googling so I don't really know where is the mistake here. I think is just about I don't achieve to return the position number in order to obtain the weight factor so that would be the question.
Code:
Public Function okCLABE(CLABE As String) As String
Dim Idx As Integer
Dim ChkSum As Long
Dim ChkVal As Integer
Dim Wgt As Long
Dim MyStr As String
Dim MyChr As String
For Idx = Len(CLABE) To 1 Step -1
[COLOR=#ff0000]MyChr = Mid$(CLABE, Idx, 1)[/COLOR]
If MyChr Mod 3 = 0 Then Wgt = Val(MyChr) * (3)
If MyChr Mod 3 = 1 Then Wgt = Val(MyChr) * (7)
If MyChr Mod 3 = 2 Then Wgt = Val(MyChr) * (1)
ChkSum = ChkSum + Wgt
Next Idx
ChkVal = (10 - (ChkSum Mod 10))
okCLABE = CLABE & Trim(Str(ChkVal))
End Function
Here it is a CLABE code to test: 03218000011835971 9=(Control digit)
Thanks in advance .