LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Canadian SIN

Good morning everyone,

On a Useform I have a textbox where the user must enter a
Social Insurance Number (Canadian).

I would like to verify if the number entered is valid.
Someone gave me the following code:

Function NumberValidation(CodeNumber)

Dim E, i, SUBT, TOT, LAST

If (IsNumeric(CodeNumber)) and (Len(CodeNumber) 8) and
(Len(CodeNumber) < 12) Then
If (Len(CodeNumber) = 11) Then
CodeNumber = Del(CodeNumber, 4, 1)
CodeNumber = Del(CodeNumber, 7, 1)
End If
TOT = 0
For i = 1 To 8
E = mid(CodeNumber,i,1)
If ((i Mod 2) = 0) Then
SUBT = (E * 2)
Else
SUBT = E
End If
If (SUBT 9) Then
SUBT = Mid(SUBT, 1, 1)*1 + Mid(SUBT, 2, 1)
End If
TOT = TOT + SUBT
Next
If (TOT 9) Then
LAST = (10 - ((Mid(TOT, 2, 1))))
Else
LAST = (10 - ((Mid(TOT, 1, 1))))
End If
If (LAST 9) Then LAST = (Mid(LAST, 2, 1))
If Mid(CodeNumber, 9, 1) = Trim(LAST) Then
NumberValidation = True
Else
NumberValidation = False
End If
Else
NumberValidation = False
End If
End Function

However, Excel doesn't seem to like it. It returns an
error message on

CodeNumber = Del(CodeNumber, 4, 1)

Anyone would have an idea why? Or maybe a better
solution ?

Thanks for your help...

Dennis
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Canadian Mortgage Formula AFQ Excel Worksheet Functions 2 March 23rd 06 03:35 AM
HOW DO I CONVERT USD TO CANADIAN ON EXCEL? rjandhitech Excel Discussion (Misc queries) 0 February 22nd 06 03:00 PM
Is there a macro for Canadian compounding DRB Excel Worksheet Functions 1 February 5th 06 05:23 AM
62% OF CANADIAN WOMEN HAVE THIS.WHAT IS IT? kresmagezi Excel Discussion (Misc queries) 1 November 9th 05 08:20 PM
Canadian Postal Code Tim Excel Programming 3 February 2nd 04 06:08 PM


All times are GMT +1. The time now is 01:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"