Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Coding a MOD9 formula
Message
De
31/08/2012 14:45:22
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Coding a MOD9 formula
Divers
Thread ID:
01552174
Message ID:
01552174
Vues:
95
I've done one of these before but it was a long time ago and I've since trailed away from VFP. Basically, I need to calculate a check digit using the MOD9 formula:


Check Digit = 9 – (Pro – (Int (Pro / 9) * 9))

I have a start and end text box on a form, you put the beginning and ending numbers in there and it generates the range of numbers and performs the calculation. I need help translating the formula to VFP code.


Example of the other formula from awhile ago:

http://www.augustana.ab.ca/~jmohr/algorithms/checkdigit.html

Using the IBM formula from that page, this code is being used:
IF LEN(proIn)<>8 AND LEN(proIn)<>9
			RETURN " "
		ENDIF 
		WS_SUM = 0			
		FOR i=1 TO 8
	 		WS_SUM = m.WS_SUM + VAL(SUBSTR(m.proIn,m.i,1)) * ( 10-m.i )
		ENDFOR		
		WS_SUM_INT = Int(WS_SUM / 11)
		WS_REM = m.WS_SUM - m.WS_SUM_INT*11
		WS_CHECK = (11 - m.WS_REM)
		IF WS_CHECK > 9
			WS_CHECK = WS_CHECK - 10
		ENDIF
		chkdig = TRANSFORM(WS_CHECK)
That works fine for that formula, but I can't get something going for the MOD9 I listed above.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform