www.pudn.com > Bar_____________________Code.rar > PrintBarcode.frm


VERSION 5.00 
Begin VB.Form PrintBarcode  
   BorderStyle     =   1  'Fixed Single 
   Caption         =   "WIA Print Barcode" 
   ClientHeight    =   3900 
   ClientLeft      =   45 
   ClientTop       =   330 
   ClientWidth     =   6975 
   Icon            =   "PrintBarcode.frx":0000 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   3900 
   ScaleWidth      =   6975 
   StartUpPosition =   2  '屏幕中心 
   Begin VB.CommandButton Command2  
      Caption         =   "Print Barcode(&P)" 
      Height          =   495 
      Left            =   4680 
      TabIndex        =   6 
      Top             =   3240 
      Width           =   2055 
   End 
   Begin VB.Frame Frame1  
      Height          =   135 
      Left            =   0 
      TabIndex        =   5 
      Top             =   2880 
      Width           =   6975 
   End 
   Begin VB.TextBox Text2  
      Height          =   2055 
      Left            =   1680 
      MultiLine       =   -1  'True 
      ScrollBars      =   3  'Both 
      TabIndex        =   2 
      Top             =   720 
      Width           =   5175 
   End 
   Begin VB.CommandButton Command1  
      Caption         =   "Build ZPLII Code(&B)" 
      Height          =   495 
      Left            =   2280 
      TabIndex        =   1 
      Top             =   3240 
      Width           =   2055 
   End 
   Begin VB.TextBox Text1  
      Height          =   375 
      Left            =   1680 
      TabIndex        =   0 
      Text            =   "G4EC7W002994YA21" 
      Top             =   120 
      Width           =   5175 
   End 
   Begin VB.Label Label2  
      AutoSize        =   -1  'True 
      Caption         =   "ZPLII Code:" 
      Height          =   180 
      Left            =   600 
      TabIndex        =   4 
      Top             =   720 
      Width           =   1080 
   End 
   Begin VB.Label Label1  
      AutoSize        =   -1  'True 
      Caption         =   "Barcode Content:" 
      Height          =   180 
      Left            =   150 
      TabIndex        =   3 
      Top             =   240 
      Width           =   1530 
   End 
End 
Attribute VB_Name = "PrintBarcode" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
 
 
Private Sub Command1_Click() 
    
    Dim strOut As String 
    Dim strCode As String 
    Dim strString As String 
    strCode = Mid(Text1.Text, 1, Len(Text1.Text) - 4) + "  " + Mid(Text1.Text, Len(Text1.Text) - 3) 
    strString = Text1.Text 
    strOut = "^XA" + vbCrLf 
    strOut = strOut + "^MD20" + vbCrLf 
    strOut = strOut + "^BY2" + vbCrLf 
    strOut = strOut + "^FO88,95^BCN,112,N,N,N^FD" + strString + "^FS" + vbCrLf 
    strOut = strOut + "^FO36,30^A0N,45,48^FD" + strCode + "^FS" + vbCrLf 
    strOut = strOut + "^FO36,223^A0N,45,48^FD" + strCode + "^FS" + vbCrLf 
    strOut = strOut + "^XZ" 
    Text2.Text = strOut 
End Sub 
 
Private Sub Command2_Click() 
    
    strOut = "这是直接发送到打印机端口的字符串" 
    '打开打印机端口,其中的”LPT1:”可能需要根据你的打印机设置而改变 
    Open "LPT1:" For Binary Access Write As #1 
    'Open "109.254.254" For Binary Access Write As #1 
    '发送给打印机,注意语句的最后一个参数必须是变量 
    Put #1, , Me.Text2.Text 
    '关闭打印机端口 
    Close #1 
End Sub