VERSION 5.00
Begin VB.UserControl UserControl1 
   ClientHeight    =   855
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   6270
   ScaleHeight     =   855
   ScaleWidth      =   6270
   Begin VB.PictureBox Barra 
      BackColor       =   &H80000005&
      Height          =   855
      Left            =   0
      ScaleHeight     =   795
      ScaleWidth      =   6195
      TabIndex        =   0
      Top             =   0
      Width           =   6255
   End
End
Attribute VB_Name = "UserControl1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' [] --------------------------------------------------------------------------- []
' [] Programa  : BarCode2of5.ocx
' [] Descricao : Gera arquivo .bmp com codigo de barras no padrao 2 de 5
' []             intervalado, a partir do numero recuperado do arquivo sitafe10.ncd
' [] Autor     : Valgney C. Ishimi
' [] Data      : 10/09/1999
' [] --------------------------------------------------------------------------- []

Public X As Integer
Public LetraAnterior As String
Public strPathFileOrigem  As String
Public strPathFileDestino As String

Public Sub ImprimeCodigoBarras()
   Dim intNum As Integer
   Dim intI   As Integer
   Dim strNum As String
   
   ' define o caminho onde se encontra a work com o numero e o arquivo onde
   ' gravar o codigo de barras
   strPathFileOrigem = "c:\sitafe\sitafe10.ncd"
   strPathFileDestino = "c:\sitafe\codbarra.bmp"
   
   ' elimina arquivos : sitafe10.ncf, sitafe11.ncf
   If Dir("c:\sitafe\codbarra.bmp") <> "" Then
     Kill "c:\sitafe\codbarra.bmp"
   End If
   
   ' inicializa as variaveis globais
   X = -5
   LetraAnterior = "A"
   
   Barra.Cls
   
   Barra.AutoRedraw = True
   
   ' le o numero a partir do qual sera gerado o codigo de barras
   Open strPathFileOrigem For Binary Access Read Lock Read As #1
   strNum = Input(44, #1)
   Close #1

   ' padrao 2 de 5 intervalado inicia com AA e termina com CA
   A
   A

   ' agrupa os numeros aos pares
   For intI = 0 To (Len(strNum) / 2) - 1
      intNum = Val(Mid(strNum, (intI * 2) + 1, 2))
      ImprimeBarra intNum
   Next

   C
   A

   Barra.Picture = Barra.Image

   SavePicture Barra.Picture, strPathFileDestino
   
   Barra.Picture = Nothing
   Barra.Cls

End Sub

Private Sub A()

   Barra.DrawWidth = 1    ' barra fina

   Select Case LetraAnterior
      Case "A":
         X = X + 30
      Case "B":
         X = X + 60
      Case "C":
         X = X + 45
      Case "D":
         X = X + 75
   End Select
   
   Barra.Line (X, 80)-(X, 700)
  
   LetraAnterior = "A"

End Sub

Private Sub B()

   Barra.DrawWidth = 1     ' barra fina

   Select Case LetraAnterior
      Case "A":
         X = X + 30
      Case "B":
         X = X + 60
      Case "C":
         X = X + 45
      Case "D":
         X = X + 75
   End Select
   
   Barra.Line (X, 80)-(X, 700)
  
   LetraAnterior = "B"

End Sub

Private Sub C()

   Barra.DrawWidth = 3     ' barra espessa

   Select Case LetraAnterior
      Case "A":
         X = X + 45
      Case "B":
         X = X + 75
      Case "C":
         X = X + 60
      Case "D":
         X = X + 90
   End Select
   
   Barra.Line (X, 85)-(X, 680)
  
   LetraAnterior = "C"

End Sub

Private Sub D()

   Barra.DrawWidth = 3     ' barra espessa

   Select Case LetraAnterior
      Case "A":
         X = X + 45
      Case "B":
         X = X + 75
      Case "C":
         X = X + 60
      Case "D":
         X = X + 90
   End Select
   
   Barra.Line (X, 85)-(X, 680)
  
   LetraAnterior = "D"

End Sub

Private Sub ImprimeBarra(intNum As Integer)

   Select Case intNum
      Case 0:
         A
         A
         D
         D
         A
      Case 1:
         B
         A
         C
         C
         B
      Case 2:
         A
         B
         C
         C
         B
      Case 3:
         B
         B
         C
         C
         A
      Case 4:
         A
         A
         D
         C
         B
      Case 5:
         B
         A
         D
         C
         A
      Case 6:
         A
         B
         D
         C
         A
      Case 7:
         A
         A
         C
         D
         B
      Case 8:
         B
         A
         C
         D
         A
      Case 9:
         A
         B
         C
         D
         A
      Case 10:
         C
         A
         B
         B
         C
      Case 11:
         D
         A
         A
         A
         D
      Case 12:
         C
         B
         A
         A
         D
      Case 13:
         D
         B
         A
         A
         C
      Case 14:
         C
         A
         B
         A
         D
      Case 15:
         D
         A
         B
         A
         C
      Case 16:
         C
         B
         B
         A
         C
      Case 17:
         C
         A
         A
         B
         D
      Case 18:
         D
         A
         A
         B
         C
      Case 19:
         C
         B
         A
         B
         C
      Case 20:
         A
         C
         B
         B
         C
      Case 21:
         B
         C
         A
         A
         D
      Case 22:
         A
         D
         A
         A
         D
      Case 23:
         B
         D
         A
         A
         C
      Case 24:
         A
         C
         B
         A
         D
      Case 25:
         B
         C
         B
         A
         C
      Case 26:
         A
         D
         B
         A
         C
      Case 27:
         A
         C
         A
         B
         D
      Case 28:
         B
         C
         A
         B
         C
      Case 29:
         A
         D
         A
         B
         C
      Case 30:
         C
         C
         B
         B
         A
      Case 31:
         D
         C
         A
         A
         B
      Case 32:
         C
         D
         A
         A
         B
      Case 33:
         D
         D
         A
         A
         A
      Case 34:
         C
         C
         B
         A
         B
      Case 35:
         D
         C
         B
         A
         A
      Case 36:
         C
         D
         B
         A
         A
      Case 37:
         C
         C
         A
         B
         B
      Case 38:
         D
         C
         A
         B
         A
      Case 39:
         C
         D
         A
         B
         A
      Case 40:
         A
         A
         D
         B
         C
      Case 41:
         B
         A
         C
         A
         D
      Case 42:
         A
         B
         C
         A
         D
      Case 43:
         B
         B
         C
         A
         C
      Case 44:
         A
         A
         D
         A
         D
      Case 45:
         B
         A
         D
         A
         C
      Case 46:
         A
         B
         D
         A
         C
      Case 47:
         A
         A
         C
         B
         D
      Case 48:
         B
         A
         C
         B
         C
      Case 49:
         A
         B
         C
         B
         C
      Case 50:
         C
         A
         D
         B
         A
      Case 51:
         D
         A
         C
         A
         B
      Case 52:
         C
         B
         C
         A
         B
      Case 53:
         D
         B
         C
         A
         A
      Case 54:
         C
         A
         D
         A
         B
      Case 55:
         D
         A
         D
         A
         A
      Case 56:
         C
         B
         D
         A
         A
      Case 57:
         C
         A
         C
         B
         B
      Case 58:
         D
         A
         C
         B
         A
      Case 59:
         C
         B
         C
         B
         A
      Case 60:
         A
         C
         D
         B
         A
      Case 61:
         B
         C
         C
         A
         B
      Case 62:
         A
         D
         C
         A
         B
      Case 63:
         B
         D
         C
         A
         A
      Case 64:
         A
         C
         D
         A
         B
      Case 65:
         B
         C
         D
         A
         A
      Case 66:
         A
         D
         D
         A
         A
      Case 67:
         A
         C
         C
         B
         B
      Case 68:
         B
         C
         C
         B
         A
      Case 69:
         A
         D
         C
         B
         A
      Case 70:
         A
         A
         B
         D
         C
      Case 71:
         B
         A
         A
         C
         D
      Case 72:
         A
         B
         A
         C
         D
      Case 73:
         B
         B
         A
         C
         C
      Case 74:
         A
         A
         B
         C
         D
      Case 75:
         B
         A
         B
         C
         C
      Case 76:
         A
         B
         B
         C
         C
      Case 77:
         A
         A
         A
         D
         D
      Case 78:
         B
         A
         A
         D
         C
      Case 79:
         A
         B
         A
         D
         C
      Case 80:
         C
         A
         B
         D
         A
      Case 81:
         D
         A
         A
         C
         B
      Case 82:
         C
         B
         A
         C
         B
      Case 83:
         D
         B
         A
         C
         A
      Case 84:
         C
         A
         B
         C
         B
      Case 85:
         D
         A
         B
         C
         A
      Case 86:
         C
         B
         B
         C
         A
      Case 87:
         C
         A
         A
         D
         B
      Case 88:
         D
         A
         A
         D
         A
      Case 89:
         C
         B
         A
         D
         A
      Case 90:
         A
         C
         B
         D
         A
      Case 91:
         B
         C
         A
         C
         B
      Case 92:
         A
         D
         A
         C
         B
      Case 93:
         B
         D
         A
         C
         A
      Case 94:
         A
         C
         B
         C
         B
      Case 95:
         B
         C
         B
         C
         A
      Case 96:
         A
         D
         B
         C
         A
      Case 97:
         A
         C
         A
         D
         B
      Case 98:
         B
         C
         A
         D
         A
      Case 99:
         A
         D
         A
         D
         A
         
   End Select

End Sub
