PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average.

How to write vba to check the last digit of hong kong ID card number

 
 
eric chan
Guest
Posts: n/a
 
      15th Oct 2003
I am an new learner to write execel vba.

Now, I come across a question about how to write vba so as to check
the last digit of hong kong id card number, says B583418(5), how do
you know the last number is 5, and how do you write this excel vba to
expedite you working.

If anyone know how to write it, please let me have the solution.

Thanks a lot !!
14/10/03
 
Reply With Quote
 
 
 
 
pk
Guest
Posts: n/a
 
      15th Oct 2003
Write the following as one line:

xLastValue = Mid(ActiveCell.FormulaR1C1,
Len(ActiveCell.FormulaR1C1) - 1, 1)

This should do it for you, but it assumes that all card
numbers are formatted the same way. That is, that the
number you want is always the next to the last character
in the string.

Hope this helps...

>-----Original Message-----
>I am an new learner to write execel vba.
>
>Now, I come across a question about how to write vba so

as to check
>the last digit of hong kong id card number, says B583418

(5), how do
>you know the last number is 5, and how do you write this

excel vba to
>expedite you working.
>
>If anyone know how to write it, please let me have the

solution.
>
>Thanks a lot !!
>14/10/03
>.
>

 
Reply With Quote
 
 
 
 
Tom Ogilvy
Guest
Posts: n/a
 
      15th Oct 2003
sStr = "B583418(5)"
? Mid(sStr,len(sStr)-1,1)
5

--
Regards,
Tom Ogilvy

eric chan <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I am an new learner to write execel vba.
>
> Now, I come across a question about how to write vba so as to check
> the last digit of hong kong id card number, says B583418(5), how do
> you know the last number is 5, and how do you write this excel vba to
> expedite you working.
>
> If anyone know how to write it, please let me have the solution.
>
> Thanks a lot !!
> 14/10/03



 
Reply With Quote
 
keepitcool
Guest
Posts: n/a
 
      15th Oct 2003

hastily put together.. without errorchecking
dont have any ID's to check here.
but it's according to the site's theory..

Sub IDTest()
Dim s$
s = InputBox("Enter ID")
MsgBox "ValidatedID: " & HongKongID(s)
End Sub


Function HongKongID(sID As String)
Dim s$, i%, n(1 To 7), r
'Theory: http://home.hkstar.com/~maukwan/fun/digit.htm

s = UCase(Left(sID, 7))
For i = 1 To 7
n(i) = Mid(s, i, 1)
Next
n(1) = 1 + (Asc(n(1)) - 65) Mod 11
For i = 1 To 7
r = r + Val(n(i)) * (9 - i)
Next
r = 11 - r Mod 11

HongKongID = s & " (" & r & ")"

End Function


keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >


(E-Mail Removed) (eric chan) wrote:

> I am an new learner to write execel vba.
>
> Now, I come across a question about how to write vba so as to check
> the last digit of hong kong id card number, says B583418(5), how do
> you know the last number is 5, and how do you write this excel vba to
> expedite you working.
>
> If anyone know how to write it, please let me have the solution.
>
> Thanks a lot !!
> 14/10/03
>


 
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
Do anyone know to validating rule for checking the Hong Kong Identity Card no new.microsoft.com Microsoft Excel Programming 1 29th Nov 2005 09:29 AM
Hong Kong man jailed for movie sharing Becky News Editions 5 7th Nov 2005 02:45 PM
how can get digital ID, because i want send e-mail to hong kong ? =?Utf-8?B?a2VubmlzY2hvbmc=?= Microsoft Access Getting Started 1 19th Oct 2004 02:27 PM
messenger video conversation hong kong mark Windows XP Messenger 0 25th Oct 2003 08:42 AM
Area Code for Hong Kong is preset to 852 Karthikeyan Rajasekharan Microsoft Outlook Discussion 0 5th Sep 2003 01:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:09 PM.