devxlogo

A Smart ID Generator

A Smart ID Generator

I wrote a unique error-proof number generator that greatly simplifies the checking of clients’ accountnumbers or other IDs used by your application. I use it in conjunction with the CheckForValid functions.For example, the CheckForValid returns True for number “203931.” The CheckFor Valid returns False fornumber “209331.”

 Function CheckForValid(Num As Long) _        As Boolean' Check for valid numberResult = Num Mod 13   If Result  0 Then        CheckForValid = False         ' if false then the number is wrongElse        CheckForValid = True        'if true the number is OKEnd IfEnd FunctionFunction Generate(Num As Long) As Long'Generates the successor of a valid 'numberIf CheckForValid(Num) Then        Generate = Num + 13        'if valid GenerateElse        Generate = -1        ' Otherwise return -1   End IfEnd Function

devx-admin

Share the Post: