*---------------------- Location Section ---------------------- * Library...........: * Class.............: Ctvatextbox * Method............: Valid() *-------------------------- Copyright ------------------------- * Author............: José Constant * Project...........: Prosal * Created...........: 29/07/96 10:23:59 * Copyright.........: (c) Terre-Engineering S.A. , 1996 *----------------------- Usage Section ------------------------ *) Description.......: Validate a VAT number. *) : if a belgian VAT number *) : Take the 7 first digits *) : divide by 97 *) : (97 - modulo) must be == last 2 digits * Scope.............: * Parameters........: None *$ Usage.............: Drop on any form, just set the control source right *% Example...........: * Returns...........: logical *------------------- Maintenance Section ---------------------- *@ Inputs:...........: * Outputs...........: * Pre-condt. invar..: * Post-condt.invar..: *? Notes.............: None * Collab.methods....: None *--Process...........: * Change log........: *-------------------------------------------------------------- LOCAL llBelge, ; lnNumerator, ; lnModulo llBelge = UPPER(SUBSTR(this.Value, 1, 2)) = "BE" lnNumerator = VAL(SUBSTR(this.Value,3,7)) lnModulo = VAL(SUBSTR(this.Value, 10, 2)) IF llBelge IF 97 - MOD(lnNumerator, 97) = lnModulo RETURN .T. ELSE = ErrorMsg(ILLEGALVALUE_LOC) RETURN .F. ENDIF ELSE *-- no control yet RETURN .T. ENDIF