recently I wrote a code in order to check the Social Insurance Number issued in Germany. I have 3 outputs, surname, dob and the given Social Insurance Number. Between 3rd and 8th digits it consists of date month and last two years of birth. however, in some cases, it does return false negative. Can anyone suggest any improvements? I am very new to VBA and coding in general, that's why feel free to check and suggest any improvements. I will post my code, an example where it gives true positive and examples where it does give false negatives. Steinbach 01.12.1991 12011291S533
false negative results for
Akyol 31.10.1993 13311093A017 Voorma 22.11.1995 53221195V018 Köhler 15.10.1997 14151097K056 Xheladini 22.10.1991 65221091X509
The function in Visual Basic
`Public Function firstDigitsSocIn(surname As String, dob As Date, socialSecurityNumber As String) As String
'defining variables (add gender after surname when data is available)
Dim dayOfMonth As Integer
Dim monthSoc As Integer
Dim yearSoc As Integer
Dim firstCharSurname As String
Dim customMadeNumber As String
'Dim genderCode As Integer enable when having genders in data set
'Dim genderCheck As Boolean
Dim resultFirst7Chars As Boolean
Dim resultInclGenderCheck As Boolean
Dim resultFinal As Boolean
'setting up variables with correct values
dayOfMonth = Day(dob)
monthSoc = Month(dob)
yearSoc = Right(Year(dob), 2)
firstCharSurname = Left(surname, 1)
'genderCode = Left(Right(socialSecurityNumber, 3), 2)
'if gender = "M" am
'custommadenumber is composed using the credentials of the user
customMadeNumber = dayOfMonth & monthSoc & yearSoc & firstCharSurname
resultFirst7Chars = StrComp(Mid(socialSecurityNumber, 3, 7), customMadeNumber, vbBinaryCompare)
'If gender = "M" And genderCode < 50 Then
'genderCheck = True
'ElseIf gender = "F" And genderCode > 50 Then
'genderCheck = True
'Else
'genderCheck = False
'End If
'resultInclGenderCheck = resultFirst7Chars And genderCheck
'resultFinal = resultInclGenderCheck And True 'put Pruefziffer check here as well
firstDigitsSocIn = resultFirst7Chars
End Function`
