Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

lulukynha

Codigo de barras 128c

Recommended Posts

Bem esse codigo é meio complexo nem eu sei muit bem explica-lo...

Mas é pra quem trabalha ou um dia ja trabalhou com codigo de barras, esse programa é bem util...

Ele gera o codigo de barras 128C, que é o codigo padrao dos correios... existem 3 tipo de codigos de barras o 128A,

128B e o 128C ( que é esse ai em baixo, e mais complicado de se achar o codigo), um amigo meu que conceguir fazer, entao achei legal compartilha-lo com você's

 

CODE
<%

'###############################################################

'GERAR CODIGO DE BARRAS DE CEP CORREIOS, CODIGO 128C

'Autor: Rafael Cavalaro

'Parametros: Cep a ser Gerado (somente números)

'Data: 25/04/2008

'###############################################################

 

Function WriteBarCode128C(cep)

Dim BarcodePattern(255)

 

BarcodePattern(0) = "212222" ' <SPACE>

BarcodePattern(1) = "222122" ' !

BarcodePattern(2) = "222221" ' "

BarcodePattern(3) = "121223" ' #

BarcodePattern(4) = "121322" ' $

BarcodePattern(5) = "131222" ' %

BarcodePattern(6) = "122213" ' &

BarcodePattern(7) = "122312" ' '

BarcodePattern(8) = "132212" ' (

BarcodePattern(9) = "221213" ' )

BarcodePattern(10) = "221312" ' *

BarcodePattern(11) = "231212" ' +

BarcodePattern(12) = "112232" ' ,

BarcodePattern(13) = "122132" ' -

BarcodePattern(14) = "122231" ' .

BarcodePattern(15) = "113222" ' /

BarcodePattern(16) = "123122" ' 0

BarcodePattern(17) = "123221" ' 1

BarcodePattern(18) = "223211" ' 2

BarcodePattern(19) = "221132" ' 3

BarcodePattern(20) = "221231" ' 4

BarcodePattern(21) = "213212" ' 5

BarcodePattern(22) = "223112" ' 6

BarcodePattern(23) = "312131" ' 7

BarcodePattern(24) = "311222" ' 8

BarcodePattern(25) = "321122" ' 9

BarcodePattern(26) = "321221" ' :

BarcodePattern(27) = "312212" ' ;

BarcodePattern(28) = "322112" ' <

BarcodePattern(29) = "322211" ' =

BarcodePattern(30) = "212123" ' >

BarcodePattern(31) = "212321" ' ?

BarcodePattern(32) = "232121" ' @

BarcodePattern(33) = "111323" ' A

BarcodePattern(34) = "131123" ' B

BarcodePattern(35) = "131321" ' C

BarcodePattern(36) = "112313" ' D

BarcodePattern(37) = "132113" ' E

BarcodePattern(38) = "132311" ' F

BarcodePattern(39) = "211313" ' G

BarcodePattern(40) = "231113" ' H

BarcodePattern(41) = "231311" ' I

BarcodePattern(42) = "112133" ' J

BarcodePattern(43) = "112331" ' K

BarcodePattern(44) = "132131" ' L

BarcodePattern(45) = "113123" ' M

BarcodePattern(46) = "113321" ' N

BarcodePattern(47) = "133121" ' O

BarcodePattern(48) = "313121" ' P

BarcodePattern(49) = "211331" ' Q

BarcodePattern(50) = "231131" ' R

BarcodePattern(51) = "213113" ' S

BarcodePattern(52) = "213311" ' T

BarcodePattern(53) = "213131" ' U

BarcodePattern(54) = "311123" ' V

BarcodePattern(55) = "311321" ' W

BarcodePattern(56) = "331121" ' X

BarcodePattern(57) = "312113" ' Y

BarcodePattern(58) = "312311" ' Z

BarcodePattern(59) = "332111" ' [

BarcodePattern(60) = "314111" ' /

BarcodePattern(61) = "221411" ' ]

BarcodePattern(62) = "431111" ' ^

BarcodePattern(63) = "111224" ' _

BarcodePattern(64) = "111422" ' `

BarcodePattern(65) = "121124" ' a

BarcodePattern(66) = "121421" ' b

BarcodePattern(67) = "141122" ' c

BarcodePattern(68) = "141221" ' d

BarcodePattern(69) = "112214" ' e

BarcodePattern(70) = "112412" ' f

BarcodePattern(71) = "122114" ' g

BarcodePattern(72) = "122411" ' h

BarcodePattern(73) = "142112" ' i

BarcodePattern(74) = "142211" ' j

BarcodePattern(75) = "241211" ' k

BarcodePattern(76) = "221114" ' l

BarcodePattern(77) = "413111" ' m

BarcodePattern(78) = "241112" ' n

BarcodePattern(79) = "134111" ' o

BarcodePattern(80) = "111242" ' p

BarcodePattern(81) = "121142" ' q

BarcodePattern(82) = "121241" ' r

BarcodePattern(83) = "114212" ' s

BarcodePattern(84) = "124112" ' t

BarcodePattern(85) = "124211" ' u

BarcodePattern(86) = "411212" ' v

BarcodePattern(87) = "421112" ' w

BarcodePattern(88) = "421211" ' x

BarcodePattern(89) = "212141" ' y

BarcodePattern(90) = "214121" ' z

BarcodePattern(91) = "412121" ' {

BarcodePattern(92) = "111143" ' |

BarcodePattern(93) = "111341" ' }

BarcodePattern(94) = "131141" ' ~

BarcodePattern(95) = "114113"

BarcodePattern(96) = "114311"

BarcodePattern(97) = "411113"

BarcodePattern(98) = "411311"

BarcodePattern(99) = "113141"

BarcodePattern(100) = "114131"

BarcodePattern(101) = "311141"

BarcodePattern(102) = "411131"

BarcodePattern(103) = "211412"

BarcodePattern(104) = "211214"

BarcodePattern(105) = "211232" 'START C

BarcodePattern(106) = "2331112" 'STOP

 

somadordigito = 105 'START C

'response.write(somadordigito & " x 1<br>")

 

barracompleta = ""

j = 1

for i=1 to len(cep) step 2

cod = mid(cep,i,2)

'response.write(cod &" x " & j & "<BR>")

somadordigito = Cint(somadordigito) + (Cint(cod)*Cint(j))

j = Cint(j) + 1

barracompleta = Cstr(barracompleta) & retornaBarra(BarcodePattern(cod))

next

 

'response.write(somadordigito & "<br>")

 

digitoVerificador = somadordigito mod 103

 

'response.write(digitoVerificador & "<br>")

 

barradigito = retornaBarra(BarcodePattern(digitoVerificador))

 

barracompleta = Cstr(retornaBarra(BarcodePattern(105))) & Cstr(barracompleta) & Cstr(barradigito) & Cstr(retornaBarra(BarcodePattern(106)))

 

response.write(barracompleta)

WriteBarCode128C = barracompleta

End Function

 

Function retornaBarra(codigo)

Const BarWidth = "2"

Const BarHeight = "70"

p = 1

barCode = ""

for i=1 to len(codigo)

bar = mid(codigo,i,1)

if p = 1 then

while(bar > 0)

barCode = barCode & "<img src='p.gif' width='" & BarWidth & "' height='" & BarHeight & "'>"

bar = Cint(bar) - 1

wend

p = 0

else

while(bar > 0)

barCode = barCode & "<img src='b.gif' width='" & BarWidth & "' height='" & BarHeight & "'>"

bar = Cint(bar) - 1

wend

p = 1

end if

next

 

retornaBarra = barCode

End Function

 

%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.