如何将图书的 ISBN 13 转换为 ISBN 10

  • 本文关键字:ISBN 转换 vb.net algorithm
  • 更新时间 :
  • 英文 :


是否有某种算法将ISBN 13转换为ISBN 10?我想在vb.net中做到这一点。

基本上是这样的。

if String.Compare(isbn13.Left(3),"978") then 
  isbn10 = isbn13.right(10)
else 
  isbn10 = "CANNOT CONVERT"
end 

记住,要将ISBN10转换为ISBN13,只需在其前面添加"978"。对于那些以979开头的ISBN13,没有真正对应的ISBN10号。毕竟,ISBN10早在2007年就被淘汰了。

我从未使用过vb.net,但我通过Google找到了一个脚本:

Public Function isbn13toisbn10(ByVal isbn13)
        Dim a As Integer
        Dim b As Integer
        Dim c As Integer
        Dim d As Integer
        Dim e As Integer
        Dim f As Integer
        Dim g As Integer
        Dim h As Integer
        Dim i As Integer
        Dim j As Integer
        Dim k As Integer
        Dim l As Integer
        Dim m As Integer
        Dim n As Integer
        Dim o As Object
        Dim n2 As Integer
        Dim isbnarr(12)
        For i = 0 To 12
            isbnarr(i) = CInt(Mid(isbn13, i + 1, 1))
        Next
        a = isbnarr(0)
        b = isbnarr(1)
        c = isbnarr(2)
        d = isbnarr(3)
        e = isbnarr(4)
        f = isbnarr(5)
        g = isbnarr(6)
        h = isbnarr(7)
        i = isbnarr(8)
        j = isbnarr(9)
        k = isbnarr(10)
        l = isbnarr(11)
        m = isbnarr(12)
        n = (d * 10) + (9 * e) + (8 * f) + (7 * g) + (6 * h) + (5 * i) + (4 * j) + (3 * k) + (2 * l)
        n2 = Int((n / 11) + 1)
        o = (11 * n2) - n
        If o = 10 Then
            o = "X"
        ElseIf o = 11 Then
            o = 0
        End If
        isbn13toisbn10 = CStr(d & e & f & g & h & i & j & k & l & o)
    End Function

来源:http://snipplr.com/view/5127/

在Google上有更多这样的搜索结果,试试吧。

最新更新