isbn check diget

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

im trying to calculate the check diget for an isbn number, i know the theory
of doing this, i need to take each individual number and multiply it with a
weighting number. my problem is, i'd like to put the isbn number in as a
whole field, ie 156054021, does anyone know how to pull off each indivutual
number, ie in a loop, 1st time round pull off the 1 and * by 7, then the 5
and * by 6, then the 6, then the 0 etc.
 
i'd like to put the isbn number in as a
whole field, ie 156054021, does anyone know how to pull off each
indivutual number, ie in a loop, 1st time round pull off the 1 and *
by 7, then the 5 and * by 6, then the 6, then the 0 etc.

strNumber = format(dwISBN, "000000000")
for p = 1 ot len(strNumber)
wDigit = CInt(mid(strNumber,p,1))
Debug.Print wDigit
' or do something useful with it
next p


Hope that helps


Tim F
 
thanks, i'll give that a go

Tim Ferguson said:
strNumber = format(dwISBN, "000000000")
for p = 1 ot len(strNumber)
wDigit = CInt(mid(strNumber,p,1))
Debug.Print wDigit
' or do something useful with it
next p


Hope that helps


Tim F
 
sorry to be a pain, but the code you gave me doesn't give me each indivual
number from the string seperatly, so that i can do a multiplication on each
seperate number, any more ideas please, thanks
 
sorry to be a pain, but the code you gave me doesn't give me each
indivual number from the string seperatly, so that i can do a
multiplication on each seperate number, any more ideas please,

I am guessing that this was meant to be a response to me: it helps if you
can stick messages on the end of the thread :-)

The code I suggested does indeed shell out individual digits -- you may
want an algorithm something like this

' put in a dummy element (0) to help indexing later on
varMultiplier = Array(Null,2,3,4,2,3,4,6,7,8)

' force the number into nine digits
strNumber = format(dwISBN, "000000000")

' prepare the accumulator
dwCheckSum = 0

' shell out individual digits
for p = 1 to len(strNumber) ' always 1 to 9...

' we need a number not a char
wDigit = CInt(mid(strNumber,p,1))

' multiply it and add it in
dwCheckSum = dwCheckSum + wDigit * varMultiplier(p)

next p

Debug.print "Checksum = " & dwCheckSum

Does that not do it for you?

Tim F
 
Back
Top