RE:verificar cta banco
Publicado por
kaditano (1 intervención) el 10/01/2009 22:54:18
En un modulo nuevo, pega esta funcion.... mas abajo te indico como se invoca
Function DC_BANC(Bank As Variant, SubBank As Variant, Account As Variant) As String
Dim sBank As String
Dim sSubBank As String
Dim sAccount As String
Dim CUENTA As String
Dim Temporal As Integer
Dim i As Integer
sBank = Format(Bank, "0000")
sSubBank = Format(Mid(SubBank, 1, 4), "0000")
sAccount = Format(Account, "0000000000")
If IsNull(Account) Then
Else
For i = 1 To 10
If Mid(Account, i, 1) = "." Then
DC_BANC = "**"
Exit Function
End If
Next
CUENTA = sAccount
End If
On Error GoTo ControlErrores
Temporal = 0
Temporal = Temporal + Mid(sBank, 1, 1) * 4
Temporal = Temporal + Mid(sBank, 2, 1) * 8
Temporal = Temporal + Mid(sBank, 3, 1) * 5
Temporal = Temporal + Mid(sBank, 4, 1) * 10
Temporal = Temporal + Mid(sSubBank, 1, 1) * 9
Temporal = Temporal + Mid(sSubBank, 2, 1) * 7
Temporal = Temporal + Mid(sSubBank, 3, 1) * 3
Temporal = Temporal + Mid(sSubBank, 4, 1) * 6
Temporal = 11 - (Temporal Mod 11)
If Temporal = 11 Then
DC_BANC = "0"
ElseIf Temporal = 10 Then
DC_BANC = "1"
Else
DC_BANC = Format(Temporal, "0")
End If
Temporal = 0
Temporal = Temporal + Mid(sAccount, 1, 1) * 1
Temporal = Temporal + Mid(sAccount, 2, 1) * 2
Temporal = Temporal + Mid(sAccount, 3, 1) * 4
Temporal = Temporal + Mid(sAccount, 4, 1) * 8
Temporal = Temporal + Mid(sAccount, 5, 1) * 5
Temporal = Temporal + Mid(sAccount, 6, 1) * 10
Temporal = Temporal + Mid(sAccount, 7, 1) * 9
Temporal = Temporal + Mid(sAccount, 8, 1) * 7
Temporal = Temporal + Mid(sAccount, 9, 1) * 3
Temporal = Temporal + Mid(sAccount, 10, 1) * 6
Temporal = 11 - (Temporal Mod 11)
If Temporal = 11 Then
DC_BANC = DC_BANC + "0"
ElseIf Temporal = 10 Then
DC_BANC = DC_BANC + "1"
Else
DC_BANC = DC_BANC + Format(Temporal, "0")
End If
If Len(Trim(CUENTA)) < 10 Then
DC_BANC = "**"
Exit Function
End If
For i = 1 To 10
If Mid(CUENTA, i, 1) = "-" Or Mid(CUENTA, i, 1) = "." Then
DC_BANC = "**"
Exit Function
End If
Next
Exit Function
ControlErrores:
DC_BANC = "**"
End Function
--------------------------------------- fin de la funcion ---------------------------------------
En el formulario tendrás tres campos BANCO,SUCURSAL y CUENTA
En el evento despues de actualizar de cada uno de esos campos, incluye lo siguiente:
Dim CALLFUNC As String
CALLFUNC = DC_BANC(Me.BANCO, Me.SUCURSAL, Me.CUENTA)
Me.DCSUCU = CALLFUNC ' En este campo meto el digito de contro devuelto
Comparo el digito devuelto con el introducido (dos ultimos digitos de la sucursal)
si son iguales no hago visible los siguientes campos y si son distintos es que ha habido error y entonces los muestro.
If Mid(Me.SUCURSAL, 5, 2) = CALLFUNC Then
Me.DCSUCU.Visible = False
Me.ERRORDC.Visible = False ' este es un campo con un mensaje
Else
Me.DCSUCU.Visible = True
Me.ERRORDC.Visible = True
End If
PD: Espero lo entiendas... Salu2