PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 1.00 average.

Check for valid national insurance number

 
 
Keith74
Guest
Posts: n/a
 
      2nd May 2007
Hi there

Does anyone have some code to check that the value in a variable is a
valid national insurance number e.g. AB123456C ?

Cheers

Keith

 
Reply With Quote
 
 
 
 
paul.robinson@it-tallaght.ie
Guest
Posts: n/a
 
      2nd May 2007
Try this, based on your example

Public Function IsNatInsurNum(DataInput As Variant) As Boolean
Dim mydata As String, Temp As Long
IsNatInsurNum = False
mydata = CStr(DataInput) 'convert to string
If Len(mydata) = 9 Then 'nine characters
If (Asc(Left(mydata, 1)) >= 65 And Asc(Left(mydata, 1)) <= 90)
Then 'first char is A to Z
If (Asc(Mid(mydata, 2, 1)) >= 65 And Asc(Mid(mydata, 2, 1)) <=
90) Then 'second char is A to Z
On Error Resume Next
Err.Clear
Temp = CDbl(Mid(mydata, 3, 6)) 'check 6 digits in middle
If Temp <> 0 Then
If (Asc(Right(mydata, 1)) >= 65 And
Asc(Right(mydata, 1)) <= 90) Then 'last char is A to Z
IsNatInsurNum = True
End If
End If
On Error GoTo 0
End If
End If
End If

End Function

regards
Paul
On May 2, 10:58 am, Keith74 <keith.wil...@sbjbc.co.uk> wrote:
> Hi there
>
> Does anyone have some code to check that the value in a variable is a
> valid national insurance number e.g. AB123456C ?
>
> Cheers
>
> Keith



 
Reply With Quote
 
Keith74
Guest
Posts: n/a
 
      2nd May 2007
Thats great, thanks Paul

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
can I build an mot and insurance check database LesleyW Microsoft Access 0 29th Apr 2008 08:46 PM
Formatting UK National Insurance Numbers XL999 Microsoft Excel Discussion 17 28th Dec 2007 10:44 PM
? Link attached - How to validate SIN (Social Insurance Number) newsgroup2003@gmail.com Microsoft Excel Worksheet Functions 5 17th Dec 2005 07:07 AM
where can i find uk tax and national insurance calculations =?Utf-8?B?RHIuQUo=?= Microsoft Excel Misc 1 17th May 2005 10:16 PM
UK Formats - National Insurance Nos and Postcodes =?Utf-8?B?U2VhbiBCaXNob3A=?= Microsoft Excel Worksheet Functions 2 16th Feb 2004 12:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:46 AM.