Rutina para EAN-13 En Visual Basic
| From: | Guillermo Buritica Tobon | Date: | Mon, 25 Nov 2002 23:33:48 +0000 |
| Subject: | Rutina para EAN-13 En Visual Basic | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-29632@lists.php.net to get a copy of this message | ||
The checksum is a Modulo 10 calculation:
Add the values of the digits in the even-numbered positions: 2, 4, 6, etc.
Multiply this result by 3.
Add the values of the digits in the odd-numbered positions: 1, 3, 5, etc.
Sum the results of steps 2 and 3.
The check character is the smallest number which, when added to the result
in step 4, produces a multiple of 10.
Example: Assume the barcode data = 001234567890
0 + 2 + 4 + 6 + 8 + 0 = 20
20 * 3 = 60
0 + 1 + 3 + 5 + 7 + 9 = 25
60 + 25 = 85
85 + X = 90 (nearest equal or higher multiple of 10), therefore X = 5
(checksum)
Here is a sample Visual Basic function to calculate the checksum:
Function Append_EAN_Checksum (RawString as String)
Dim Position as Integer
Dim CheckSum as Integer
CheckSum = 0
For Position = 2 to 12 step 2
Checksum = Checksum + Val(Mid$(RawString, Position, 1))
Next Position
CheckSum = CheckSum * 3
For Position = 1 to 11 Step 2
CheckSum = CheckSum + Val(Mid$(RawString, Position, 1))
Next Position
CheckSum = CheckSum Mod 10
CheckSum = 10 - CheckSum
If CheckSum = 10 Then
CheckSum = 0
End If
Append_Ean_Checksum = RawString & Format$(CheckSum, "0")
End Function
----- Original Message -----
From: "Rubén Cruz Olivares" <rubenc@rdc.cl>
To: <lista@phpes.com>
Sent: Monday, November 25, 2002 2:48 PM
Subject: [PHP-ES] Rutina para EAN-13
>
> Estimados Listeros:
>
> Alguién tiene la rutina en Php para sacar el Digito verificador de un
código
> EAN-13, si me la pudiera enviar, o si la tiene en otro lenguaje, me da lo
> mismo (C, CLipper, Java, perl, etc...)
>
> Sin otro particular....muchas gracias
>
>
> Ruben
>
>
>
> ---------------------------------------------------------------------
> Archivo On-line: http://www.phpes.com/
> via news: news://news.phpes.com/
> Manual PHP en español: http://www.php.net/manual/es/
> Para dar de baja la suscripción, mande un mensaje a:
> lista-unsubscribe@phpes.com
>
>