ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 제프라 제어 프로그램
    IT/VB6.0 2024. 10. 16. 07:39
    728x90
    반응형

    간단한 인쇄 프로그램...

    제브라 프린터....Serial 통신으로 인쇄

    zplguide_x14.pdf
    4.81MB
    zplguide_x10.pdf
    3.75MB

    1) 프린터 인쇄 모듈

     

    Public Sub PrintLabel(ByVal sNo As String, ByVal sNW As String, ByVal sGW As String, ByVal sBar As String, ByVal sB As String, ByVal sB2 As String)
        '
        '
        Dim iQty As Long
        '
        iQty = 1
        '
        ' 2008-12-14
        If CheckPass.Value = 1 Then
            Call CheckLabel
        End If
        '' Call SetComPort(1, 2, 1)
        Call SetComPort(1, 2, 1)
        '
        '' Call SendComData(1, "~HS")   ''상태 확인 명령어
        Call SendComData(1, "^XA~TA000~JSN^LT0^MMT^MNW^MTT^PON^PMN^LH0,0^JMA^PR4,4^MD0^JUS^LRN^CI0^XZ")
        Call SendComData(1, "^^XA^LL1594")   '' 길이
        Call SendComData(1, "^PW1146")   '' 폭
        '
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        Call SendComData(1, "^FT246,1397^A0B,65,65^FH\^FD" & sNo & "^FS")
        Call SendComData(1, "^FT127,1077^A0B,65,65^FH\^FD" & sNW & "^FS")
        Call SendComData(1, "^FT244,1077^A0B,65,65^FH\^FD" & sGW & "^FS")
        Call SendComData(1, "^BY4,3,120^FT446,1380^BCB,,N,N")
        Call SendComData(1, "^FD" & sBar & "^FS")
        '' Print #1, "^BY2,3.0^FO90,60^B3N,N,88,N,Y^FD" & sBar & "^FS"  '''바코드
        ''Call SendComData(1, "^FT521,1474^A0B,46,45^FH\^FD" & sB & "^FS")
        Call SendComData(1, "^FT500,1243^A0B,46,54^FH\^FD" & sB2 & "^FS")
       
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
       
        Call SendComData(1, "^FT836,1397^A0B,65,65^FH\^FD" & sNo & "^FS")
        Call SendComData(1, "^FT717,1077^A0B,65,65^FH\^FD" & sNW & "^FS")
        Call SendComData(1, "^FT834,1077^A0B,65,65^FH\^FD" & sGW & "^FS")
        Call SendComData(1, "^BY4,3,120^FT1036,1380^BCB,,N,N")    ''' 7,3,122
        ''Call SendComData(1, "^FD>;" & sBar & ">67^FS")
        Call SendComData(1, "^FD" & sBar & "^FS")
       
        ''Call SendComData(1, "^FT1112,1474^A0B,46,45^FH\^FD" & sB & "^FS")
        Call SendComData(1, "^FT1090,1243^A0B,46,54^FH\^FD" & sB2 & "^FS")
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        Call SendComData(1, "^PQ1,0,1,Y^XZ")
        '
        TextM = "<<" & Format(Now, "hh:mm:ss") & "_" & GetComData(1) & vbCrLf & TextM
        '
        Call CloseComPort(1)
    End Sub

     

     

    2) 프린터 상태 확인

     

    Public Function CheckLabel()
        ''
        Dim sText As String
        '
        Call SetComPort(1, 2, 1)
        '
        Call SendComData(1, "~HS")
        '
        sText = Trim(GetComData(1))
        '
        If sText = "" Then
            Label프린터 = "프린터 상태 : NG(통신이상) "
        Else
            Label프린터 = "프린터 상태 : OK "
            '
            If Mid(sText, 6, 3) <> "0,0" Then
                Label프린터 = "프린터 상태 : 리본 또는 Head 이상 "
            End If
            TextM = sText
        End If
        '
    End Function

     

     

    3) Serial Port 열기 및 설정

     

    Sub SetComPort(ByVal iComm As Long, ByVal iPort As Long, ByVal iRts As Long)
        '
        ' 통신 Port 설정
        '
        Dim rBps As String
        Dim rData As String
        Dim rStop As String
        Dim rParity As String
        '
        On Error GoTo Port_Err
        '
        If MSComm(iComm).PortOpen = True Then
            '' MsgBox "이미 Port가 Open 되어 있습니다", vbInformation, "확인"
            Exit Sub
        End If
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        '   RS-232C PORT OPEN
        '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        If iGblComm = 0 Then
            ' 속도
            If iComm = 0 Then
                rBps = "4800"
            Else
                rBps = "9600"
            End If
            ' Data bit
            rData = "8"
            ' Stop Bit
            rStop = "1"
            ' Parity
            rParity = "N"
        Else
            iPort = iGblPort(iComm)
            rBps = sGblBps(iComm)
            rData = sGblData(iComm)
            rStop = sGblStop(iComm)
            rParity = sGblParity(iComm)
        End If
        '
        If iComm = 0 Then
            Label저울 = "저울 연결 상태 : OK"
        Else
            Label프린터 = "바코드 연결 상태 : OK"
        End If
        '
        MSComm(iComm).CommPort = iPort
        MSComm(iComm).Settings = rBps & "," & rParity & "," & rData & "," & rStop ' "9600,e,7,1"
        MSComm(iComm).InputLen = 0
        MSComm(iComm).InBufferSize = Val(1024)
        MSComm(iComm).OutBufferSize = Val(512)
        '
        If iRts = 1 Then
            MSComm(iComm).RTSEnable = True
        Else
            MSComm(iComm).RTSEnable = False
        End If
        '
        MSComm(iComm).PortOpen = True
        '
    Exit Sub
    '
    Port_Err:
        '' MsgBox Error$
        TextM.Text = Error$
        '
        If iComm = 0 Then
            Label저울 = "저울 연결 상태 : " & Error$
        Else
            Label프린터 = "바코드 연결 상태 :" & Error$
        End If
        Resume Next
    End Sub

     

    4) 데이터 전송 (Serial Port 로)

     

    Public Sub SendComData(ByVal iComm As Long, ByVal sData As String)
    '
    ' 데이터 전송 (To COM PORT)
    '
    On Error GoTo Send_Err
        '
        MSComm(iComm).Output = sData
        '
        TextM = TextM & vbCrLf & sData
        '
    Exit Sub
    Send_Err:
        Beep
        Resume Next
    End Sub

     

     

    5) Serial Port 닫기

     

    Public Sub CloseComPort(ByVal iComm As Long)
    '
        '   Rs-232C Port Close
        On Error GoTo Port_Err1
        '
        If MSComm(iComm).PortOpen = False Then
            ''MsgBox "이미 Port가 닫혀 있습니다", vbInformation, "확인"
            Exit Sub
        End If
        '
        MSComm(iComm).PortOpen = False
        '
    Exit Sub
    Port_Err1:
        MsgBox Error$
        Resume Next
    End Sub

    태그
    728x90

    'IT > VB6.0' 카테고리의 다른 글

    ZM400 바코드 프린터 인쇄 프로그램  (0) 2024.10.17
    매크로를 이용한 Excel제어 명령 작성법  (4) 2024.10.17
    VB6.0 Serial 통신 TIP  (0) 2024.10.16
    COM+ 작성 및 사용법  (1) 2024.10.15
    SCROLL  (1) 2024.10.15
Designed by Tistory.