Function checkcnp(cnp As String) As Boolean
Dim b As Boolean
Let b = False
Let mul = "279146358279"
If Len(cnp) = 13 Then
Let v = 0
For i = 1 To 12 Step 1
v = v + Val(Mid(cnp, i, 1)) * Val(Mid(mul, i, 1))
Next i
v = v Mod 11
If v <= 9 Then
If Val(Mid(cnp, 13, 1)) = v Then
b = True
End If
Else
If Val(Mid(cnp, 13, 1)) = 1 Then
b = True
End If
End If
End If
checkcnp = b
End Function
The following function will eliminate special romanian characters from a text and use only the english alphabet instead:
Function fara_diacritice(t As String) As String
Dim a As Integer
For i = 1 To Len(t)
a = Asc(Mid(t, i, 1))
t = Mid(t, 1, i - 1) + Chr$(a) + Mid(t, i + 1, Len(t) - i)
If Mid(t, i, 1) = "Î" Then
t = Mid(t, 1, i - 1) + "I" + Mid(t, i + 1, Len(t) - i)
End If
If Mid(t, i, 1) = "î" Then
t = Mid(t, 1, i - 1) + "i" + Mid(t, i + 1, Len(t) - i)
End If
If Mid(t, i, 1) = "Â" Then
t = Mid(t, 1, i - 1) + "A" + Mid(t, i + 1, Len(t) - i)
End If
If Mid(t, i, 1) = "â" Then
t = Mid(t, 1, i - 1) + "a" + Mid(t, i + 1, Len(t) - i)
End If
Next i
fara_diacritice = t
End Function
That's it for today tips and tricks.




Niciun comentariu:
Trimiteți un comentariu