How to check if a social security number is valid ?? (Views: 713)
Problem/Question/Abstract: How to check if a social security number is valid ?? note : only tested on the dutch social security numbers Answer: function CheckFiscaalNumber(Value: string): boolean; var n1, n2, n3, n4, n5, n6, n7, n8, n9: integer; s1, s2, s3, s4, s5, s6, s7, s8: integer; totaal, rest: integer; begin if StrToInt(Value) > 10000000 then begin if Length(Value) >= 8 then begin if Length(Value) = 8 then begin Value := '0' + Value; end; n1 := StrToInt(copy(Value, 1, 1)); n2 := StrToInt(copy(Value, 2, 1)); n3 := StrToInt(copy(Value, 3, 1)); n4 := StrToInt(copy(Value, 4, 1)); n5 := StrToInt(copy(Value, 5, 1)); n6 := StrToInt(copy(Value, 6, 1)); n7 := StrToInt(copy(Value, 7, 1)); n8 := StrToInt(copy(Value, 8, 1)); n9 := StrToInt(copy(Value, 9, 1)); s1 := n1 * 9; s2 := n2 * 8; s3 := n3 * 7; s4 := n4 * 6; s5 := n5 * 5; s6 := n6 * 4; s7 := n7 * 3; s8 := n8 * 2; totaal := s1 + s2 + s3 + s4 + s5 + s6 + s7 + s8; rest := totaal mod 11; if rest <> n9 then begin Result := False; end else begin Result := True; end; end else begin Result := False; end; end else begin Result := False; end; end; |