codigo bancario IBAN
Publicado por joaquin fernandez (5 intervenciones) el 06/12/2013 19:07:31
Hola, ¿alguien me podría indicar como convertir el código bancario BBAN en IBAN, en un modulo en Acces?
gracias
gracias
Valora esta pregunta


0
Function HallarIBAN(CCC As String) As String
Dim DigControl As String
DigControl = 98 - CalcularModulo(CCC & "142800", 97)
HallarIBAN = "ES" & Format(DigControl, "00") & CCC
End Function
Function CalcularModulo(Numero As String, Modulo As Integer) As String
Dim Dividendo As Long
Dim VoyPor As Integer
Dim Resto As Integer
VoyPor = 1
Do While VoyPor <= Len(Numero)
Dividendo = Resto & Mid(Numero, VoyPor, 1)
Resto = Dividendo Mod Modulo
VoyPor = VoyPor + 1
Loop
CalcularModulo = Resto
End Function
Dim A As String
A = "3016 0153 41 1234567890 142800"
A = Replace(A, " ", "")
For N = 1 To Len(A)
DIVIDENDO = RESTO & Mid(A, N, 1)
RESTO = DIVIDENDO Mod 97
Next N
IBAN = "IBAN" & " " & "ES" & Format$((98 - RESTO), "00") & " "
For N = 1 To Len(A)-6 Step 4
IBAN = IBAN & " " & Mid(A, N, 4)
Next N
MsgBox "CCC " & left$( A ,20) & " " & IBAN
Resto 98-Resto Nuevo Resto
0 98 1*
1 97 0*
2 96 96
3 95 95
4 94 94
....
....
93 5 5
94 4 4
95 3 3
96 2 2
resto (98- resto)codigo
98 0 98
98 1 97
98 2 96
98 3 95
98 4 94
98 5 93
98 6 92
98 7 91
98 8 90
98 9 89
98 10 88
98 11 87
98 12 86
98 13 85
98 14 84
98 15 83
98 16 82
98 17 81
98 18 80
98 19 79
98 20 78
98 21 77
98 22 76
98 23 75
98 24 74
98 25 73
98 26 72
98 27 71
98 28 70
98 29 69
98 30 68
98 31 67
98 32 66
98 33 65
98 34 64
98 35 63
98 36 62
98 37 61
98 38 60
98 39 59
98 40 58
98 41 57
98 42 56
98 43 55
98 44 54
98 45 53
98 46 52
98 47 51
98 48 50
98 49 49
98 50 48
98 51 47
98 52 46
98 53 45
98 54 44
98 55 43
98 56 42
98 57 41
98 58 40
98 59 39
98 60 38
98 61 37
98 62 36
98 63 35
98 64 34
98 65 33
98 66 32
98 67 31
98 68 30
98 69 29
98 70 28
98 71 27
98 72 26
98 73 25
98 74 24
98 75 23
98 76 22
98 77 21
98 78 20
98 79 19
98 80 18
98 81 17
98 82 16
98 83 15
98 84 14
98 85 13
98 86 12
98 87 11
98 88 10
98 89 9
98 90 8
98 91 7
98 92 6
98 93 5
98 94 4
98 95 3
98 96 2
98 97 1
' Esta función devolverá el Código IBAN de la cuenta, pero OJO!!!
' sólo sirve para ESPAÑA, ya q sólo tengo información de ES=(E = 14, S= 28)
Dim IB As Variant
Dim DigControl As String
Dim Resto As Variant
Dim cociente As Variant
' Le paso 20 dígitos 0012 0345 0300 0006 7890
IB = Me.[CUENTA BANCO]
' Le añade a la cola 0012 0345 0300 0006 7890 142800
IB = IB & "142800"
' Aquí me peta, el error es: Desbordamiento...
cociente = CDec(IB) / 97
Resto = IB - (Int(cociente) * 97)
' Si todo ha ido bien, DigControl es 7
DigControl = CStr(98 - Resto)
' Si DigControl SÓLO es de un dígito, anteponer un 0 para que sea 07
If Len(Trim(DigControl)) = 1 Then DigControl = "0" & DigControl
' IBAN = ES + 07 + 0012 0345 0300 0006 7890
IB = "ES" & DigControl & Me.[CUENTA BANCO]
' La función devolverá: ES07 0012 0345 0300 0006 7890(por supuesto sin espacios...)
Me.IBAN = IB