Xbasic

BankRoutingValid Function

Syntax

Result_Flag as L = bankroutingvalid(C routing_num )

Arguments

Result_Flag

.T. (TRUE) indicates that the bank routing number passes the checksum test.

routing_num

A character string containing 9 numeric characters.

Description

Returns .T. if routing_num is a valid bank routing number.

Discussion

The BankRoutingValid() function takes a bank routing number as a character string and returns true or false if the bank routing number is valid. First the function strips out any non-numeric characters (like dashes or spaces) and makes sure the resulting string's length is nine digits. Then it multiplies the first digit by 3, the second by 7, the third by 1, the fourth by 3, the fifth by 7, the sixth by 1, etc., and sums the result.

(*7* x 3) + (*8* x 7) + (*9* x 1) +
(*4* x 3) + (*5* x 7) + (*6* x 1) +
(*1* x 3) + (*2* x 7) + (*4* x 1) = 160

If this sum is an integer multiple of 10 (e.g., 10, 20, 30, 40, 50,...) then the number is valid, as far as the checksum is concerned.

? BankRoutingValid( "7 8 9 4 5 6 1 2 3" )
= .F.