So it's either 9999999 or the required Medicaid formatted string that return a value of True.
Samples:
AZ12345Z
NP54321J
EM17345P
So far I have 2 functions working together but I made a mess of the logic!!
Thank you
Public Function isAlpha(cChar As Integer) As Boolean
'returns true if its a alphabetic character
isAlpha = IIf((cChar >= 65 And cChar <= 90) Or (cChar >= 97 And cChar <= 122), True, False)
End Function
Public Function CheckMedicaidIDFormat(strMedicaidID As String) As Boolean
Dim blnResult As Boolean
If strMedicaidID = "99999999" or If Len(strMedicaidID) = 8 And isAlpha(Left(strMedicaidID, 2)) = True And IsNumeric(Mid(strMedicaidID, 3, 5)) = True And isAlpha(Right(strMedicaidID, 1)) = True Then
blnResult = True
Else
blnResult = False
End If
CheckMecicaidIDFormat = blnResult
End Function
While RegEx
is a good general solution for this type of problem, in this case a simple Like
comparison will do
Function IsValid(strIn As String) As Boolean
IsValid = (strIn Like "[A-Z][A-Z]#####[A-Z]") Or strIn = "99999999"
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With