您的位置首页百科知识

怎样用vba识别一段字符是不是ISIN或者SEDOL?

怎样用vba识别一段字符是不是ISIN或者SEDOL?

的有关信息介绍如下:

怎样用vba识别一段字符是不是ISIN或者SEDOL?

几天前就看到这个问题了,一直没有回答是不知道题主说的ISIN是什么~今天得空自己去搜索了下:

关于最后一位校验码的规则,没找到中文的说明,有一篇来自维基的英文说明:

Apple Inc.: ISIN US0378331005, expanded from CUSIP037833100 The main body of the ISIN is the original CUSIP, assigned in the 1970s. The country code "US" has been added on the front, and an additional check digit at the end. The country code indicates the country of issue. The check digit is calculated using the Luhn algorithm.

Convert any letters to numbers:

U = 30, S = 28. US037833100 -> 3028037833100

Collect odd and even characters:

3028037833100 = (3, 2, 0, 7, 3, 1, 0), (0, 8, 3, 8, 3, 0)

Multiply the group containing the rightmost character (which is the FIRST group) by 2:

(6, 4, 0, 14, 6, 2, 0)

Add up the individual digits:

(6 + 4 + 0 + (1 + 4) + 6 + 2 + 0) + (0 + 8 + 3 + 8 + 3 + 0) = 45

Take the 10s modulus of the sum:

45 mod 10 = 5

Subtract from 10:

10 - 5 = 5

Take the 10s modulus of the result (this final step is important in the instance where the modulus of the sum is 0, as the resulting check digit would be 10).

5 mod 10 = 5

So the ISIN check digit is five.

然而我的英文并不是很好。。。所以只能凭借猜测写一下。。。

根据以上规则得到VBA代码如下:

这里只有对校验码进行校验,正确返回TRUE,错误返回FALSE。

因为不清楚其他规则,没有对前面的国家代码、长度,以及其他编码规则进行检验,以上。