|
|
Subject:
BooklandEAN <--> ISBN Conversion for MS Access
Category: Computers > Programming Asked by: oh_one_one-ga List Price: $20.00 |
Posted:
24 Sep 2004 14:42 PDT
Expires: 29 Sep 2004 09:48 PDT Question ID: 405981 |
I am an intermediate user of Access but don't have the patience to learn VB. I need a very simple Access function (or piece of VBAccess code, if you can show me how to plug it in) that will simply convert: Bookland EAN <==> ISBN bidirectionally. I'd basically like to plug, for example, a flat file of EANs into the db and be able to run a query that spits out the EAN and its corresponding ISBN. And vice versa. Code abounds on the internet that shows how this can be done, and the math isn't too complicated, but I can't find it scripted in VB for Access. Tip for a complete answer by 9/27. |
|
There is no answer at this time. |
|
Subject:
Re: BooklandEAN <--> ISBN Conversion for MS Access
From: donessive-ga on 28 Sep 2004 18:28 PDT |
Well, here's one side of the conversion in VBA. I'm a VB expert and not an Access expert but was able to run this in VB and confirm the conversion. I also pasted it into Access to confirm the code is valid: Public Function ISBN2EAN13(ByVal sISBN As String) As String Dim iLoop As Integer Dim iEvenChkSum As Integer Dim iOddChkSum As Integer Dim sEAN As String Dim sChar As String Dim iChkSum As Integer sEAN = "978" If Len(sISBN) > 0 Then 'Append the ISBN to the EAN-13 removing any dashes For iLoop = 1 To Len(sISBN) - 1 sChar = Mid(sISBN, iLoop, 1) If IsNumeric("-" & sChar) Then sEAN = sEAN & sChar End If Next iLoop 'Calculate the EAN-13 checksum digit If Len(sEAN) = 12 Then For iLoop = 1 To Len(sEAN) If iLoop Mod 2 = 1 Then iOddChkSum = iOddChkSum + Int(Mid(sEAN, iLoop, 1)) Else iEvenChkSum = iEvenChkSum + Int(Mid(sEAN, iLoop, 1)) End If Next iLoop iChkSum = (iEvenChkSum * 3) + iOddChkSum iChkSum = 10 - (iChkSum Mod 10) If iChkSum = 10 Then iChkSum = 0 sEAN = sEAN & CStr(iChkSum) ISBN2EAN13 = sEAN Else 'Error here - length is not correct End If Else 'Error here - ISBN is blank End If End Function |
Subject:
Re: BooklandEAN <--> ISBN Conversion for MS Access
From: donessive-ga on 28 Sep 2004 18:29 PDT |
I'll post the other conversion later. Hope this at least helps you. |
Subject:
Re: BooklandEAN <--> ISBN Conversion for MS Access
From: donessive-ga on 28 Sep 2004 18:44 PDT |
Here's the other conversion! Enjoy! Private Function EAN2ISBN(ByVal sEAN As String) As String Dim iLoop As Integer Dim sISBN As String Dim iChkSum As Integer If Len(sEAN) = 13 Then 'Get the ISBN core 9 digits sISBN = Mid(sEAN, 4, 9) 'Calc the ISBN checksum digit For iLoop = 1 To Len(sISBN) iChkSum = iChkSum + (Int(Mid(sISBN, iLoop, 1)) * iLoop) Next iLoop 'If checksum mod is 10 then append an X otherwise the digit iChkSum = iChkSum Mod 11 If iChkSum = 10 Then sISBN = sISBN & "X" Else sISBN = sISBN & CStr(iChkSum) End If EAN2ISBN = sISBN Else 'EAN length error! End If End Function |
Subject:
Re: BooklandEAN <--> ISBN Conversion for MS Access
From: oh_one_one-ga on 29 Sep 2004 08:30 PDT |
Awesome, thanks, I'll test them out. Did you write these from scratch or were you able to find them somewhere? |
Subject:
Re: BooklandEAN <--> ISBN Conversion for MS Access
From: oh_one_one-ga on 29 Sep 2004 09:48 PDT |
Awesome, thank you so much, this is really useful for me and totally works well in my database. donessive, I owe you one! |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |