0
In Mozambique there is a unique tax identification number (Nuit), and this number takes 9 digits.
How an application would look to validate the Nuit meeting the following conditions?
If there are more(+) or less(-) than nine(9) digits, say "invalid Nuit."
Should accept only numbers, if they are not numbers say "please type only numbers"
I have here the algorithm:
Private Sub CommandButton1_Click()
v = validarnuit(TextBox1.Text)
MsgBox v
End Sub
Function validarnuit(nuit)
Dim cd As Double
Dim valido As String
valido = "Nuit Invalido"
If Len(nuit) = 9 Then
If IsNumeric(nuit) Then
If nuit <> 0 Then
cd = Mid(nuit, 8, 1) * 2
cd = cd + Mid(nuit, 7, 1) * 3 + _
cd = cd + Mid(nuit, 6, 1) * 4 + _
cd = cd + Mid(nuit, 5, 1) * 5 + _
cd = cd + Mid(nuit, 4, 1) * 6 + _
cd = cd + Mid(nuit, 3, 1) * 7 + _
cd = cd + Mid(nuit, 2, 1) * 2 + _
cd = cd + Mid(nuit, 1, 1) * 3 + _
cd = 11 - (cd Mod 11)
If cd = 9 Then
valido = "good"
End If
End If
End If
End If
validarnuit = valido
End Function
If the cd
fore equal to 11, is false and does not validate; if it is equal to 10 also does not validate; only validates if cd
is equal to 9. Image if the division is equal to 2, this would be 11-2 = cd 9 and validate. I tried using this code above but did not give 9.
Does anyone have an effective idea of how to do this?
"but using Msaccess.vba", leads me to ask, is developing the EM Msaccess application or is developing an application that garter a Msaccess?
– Omni
I am densevolver an application in vba that connects Msaccess.
– user7752
What a mess..! I did my editing and only later I saw that this is a chameleon question, Waste of time... @Omni, feel free to revert to the version that gave rise to your answer (or as close as possible).
– brasofilo
@brasofilo the answer remains valid for all editions, the only difference was the number of digits that the OP wanted to validate.
– Omni