'Functions upgraded from 15 digits from 15 digits
Function getnewidcard (byval IDcard as string) AS STRING
DIM I, S AS INTEGER
DIM WI () AS String = Split ("7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1", "," )
DIM WF () AS String = Split ("1,0, x, 9, 8, 7, 6, 5, 4, 3, 2", ",")
IF MID (IDCard, 7, 2)> = MID (now.addyears (-14) .year, 3, 2) THEN
IDCARD = MID (IDCard, 1, 6) & "18" & MID (IDCard, 7, 9)
Else
IDCARD = MID (IDCard, 1, 6) & "19" & MID (IDCard, 7, 9)
END IF
For i = 0 TO 16
S = Wi (i) * MID (IDCARD, I 1, 1)
NEXT
Return Idcard & WF (S Mod 11)
END FUNCTION