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

时间:2015-08-28 16:02:05

标签: vb.net algorithm

是否有一些算法可以从ISBN 13转换为ISBN 10?我想在vb.net中这样做。

2 个答案:

答案 0 :(得分:1)

从根本上说,就是这样。

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年逐步淘汰。

答案 1 :(得分:-1)

我从未使用过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上有更多这样的结果,试一试。