Prueba si te sirve este código:
************************************************
* COMPROBACIÓN DE LOS DÍGITOS DE CONTROL EN CCC
*
* m.ccc1 --> Entidad (4 Caracteres con ceros por la izda.)
* m.ccc2 --> Oficina (4 Caracteres con ceros por la izda.)
* m.ccc3 --> Digito Control (2 Caracteres con ceros por la izda.)
* m.ccc4 --> Cuenta (10 Caracteres con ceros por la izda.)
************************************************
m.cad1 = m.ccc1 + m.ccc2
m.cad2 = m.ccc4
m.dc = m.ccc3
*-
*-- Obtener valores por posición de Entidad y Oficina
*---
m.unidad = val(right(m.cad1,1)) * 6
m.decena = val(substr(m.cad1,7,1)) * 3
m.centena = val(substr(m.cad1,6,1)) * 7
m.umillar = val(substr(m.cad1,5,1))*9
m.dmillar = val(substr(m.cad1,4,1)) * 10
m.cmillar = val(substr(m.cad1,3,1)) * 5
m.umillon = val(substr(m.cad1,2,1)) * 8
m.dmillon = val(left(m.cad1,1)) * 4
m.digito1 = mod((m.unidad+m.decena+m.centena+m.umillar+m.dmillar+m.cmillar+m.umillon+m.dmillon),11)
m.digito1 = 11-m.digito1
* Excepciones
if m.digito1 = 10
m.digito1 = 1
endif
if m.digito1 = 11
m.digito1 = 0
endif
*-
*-- Obtener valores por posición de Nº Cuenta
*---
m.unidad = val(right(m.cad2,1)) * 6
m.decena = val(substr(m.cad2,9,1)) * 3
m.centena = val(substr(m.cad2,8,1)) * 7
m.umillar = val(substr(m.cad2,7,1)) * 9
m.dmillar = val(substr(m.cad2,6,1)) * 10
m.cmillar = val(substr(m.cad2,5,1)) * 5
m.umillon = val(substr(m.cad2,4,1)) * 8
m.dmillon = val(substr(m.cad2,3,1)) * 4
m.cmillon = val(substr(m.cad2,2,1)) * 2
m.mmillon = val(left(m.cad2,1)) * 1
m.digito2 = mod((m.unidad+m.decena+m.centena+m.umillar+m.dmillar+m.cmillar+m.umillon+m.dmillon+m.cmillon+m.mmillon),11)
m.digito2 = 11-m.digito2
* Excepciones
if m.digito2 = 10
m.digito2 = 1
endif
if m.digito2 = 11
m.digito2 = 0
endif
m.DigitoControl = alltrim(str(m.digito1)) + alltrim(str(m.digito2))
if m.dc == m.DigitoControl
messagebox("Correcto")
else
messagebox("Erroneo")
endif
Un saludo.
Jose A. Blasco
Zaragoza - España
Visual FoxPro 9 SP2