Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default Creating a check digit

Hey guys, I need you help, creating a check digit.

I have a number: 012Q
Base sequence:
0123456789BCDFGHJKLMNPQRSTVWXYZ
I need to return the positions of each char:
0 1 2 22

Then something like: =MOD('0'+'1'+'2'+'22',31)+1
That will result in: 26

The end value I need returned is T as T is at position 26

Your help is much appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Creating a check digit

Sub AAA()
sStr = "0123456789BCDFGHJKLMNPQRSTVWXYZ"
ReDim arr(0 To Len(sStr) - 1)
For i = 1 To Len(sStr)
arr(i - 1) = Mid(sStr, i, 1)
Next

sStr1 = "012Q"
For i = 1 To Len(sStr1)
res = Application.Match(Mid(sStr1, i, 1), _
arr, 0)
If Not IsError(res) Then
lSum = lSum + res - 1
Else
MsgBox "Bad code"
Exit Sub
End If
Next
res = lSum Mod 31
MsgBox arr(res) & " " & lSum
End Sub

lSum is actually 25, but that gives the 26th element of the array ("T")
since it is zero based.

--
Regards,
Tom Ogilvy


"Patrick" wrote in message
...
Hey guys, I need you help, creating a check digit.

I have a number: 012Q
Base sequence:
0123456789BCDFGHJKLMNPQRSTVWXYZ
I need to return the positions of each char:
0 1 2 22

Then something like: =MOD('0'+'1'+'2'+'22',31)+1
That will result in: 26

The end value I need returned is T as T is at position 26

Your help is much appreciated.



Reply
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
Removing a check digit cwd58 Excel Discussion (Misc queries) 3 June 22nd 06 06:07 PM
Creating a Check Digit Ilan Charts and Charting in Excel 1 December 3rd 05 12:43 PM
Mod-10 Check Digit Union70 Excel Worksheet Functions 1 March 24th 05 11:35 PM
Check last digit in cell NacellesEng Excel Programming 1 March 14th 05 09:26 PM
Mod-10 Check Digit Union70 Excel Worksheet Functions 4 March 8th 05 07:58 AM


All times are GMT +1. The time now is 01:11 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"