[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6026
  • Last Modified:

help, how I can print a logo in the printing metric epson tm-t88iii with esc/pos codes

aid please, I have a printer Epson metric ton-t88iii, already can cause that it removes the drawer from money, but cannot do that it prints the logo that it has in the memory, I require the code please esc/pos to print the logo, thanks for its aid
0
dioniico_salazar
Asked:
dioniico_salazar
  • 2
2 Solutions
 
BigRatCommented:
You'll nedd the file okipos-tm88.rtf which you should find on the Epson site. See the section "Bit-Image Commands". If you can't find it on the web I'll mail you a copy.
0
 
dioniico_salazarAuthor Commented:
please sendmy a copy of "okipos-tm88.rft", because I can´t find the file.
thank for you help
0
 
BigRatCommented:
OK, please put your E-Mail address in your E-E profile and I'll get someone in the offce to mail it to you. It is an RTF file and quite big, so I can't post it here.
0
 
saravananvgCommented:
Hello Sir,

   These are the 2 vb sample codes for printing the bitmaps using tm88ii with coptr5.ocx. You can also download the sample vb applications for opos from the net.

' Step 3  Print Bitmaps
Option Explicit

Private Sub cmdPrint_Click()

    Dim ESC As String * 1
    Dim fDate As String

    ESC = Chr(&H1B)
    fDate = Format(Now, "mmmm dd, yyyy  AM/PM h:mm")

    With OPOSPOSPrinter1
    'Print a registered bitmap.
        .PrintNormal PTR_S_RECEIPT, ESC + "|1B"
       
        .PrintNormal PTR_S_RECEIPT, ESC + "|N" + "123xxstreet,xxxcity,xxxxstate " + vbLf
        .PrintNormal PTR_S_RECEIPT, ESC + "|rA" + "TEL 9999-99-9999   C#2" + vbLf
        .PrintNormal PTR_S_RECEIPT, ESC + "|cA" + fDate + vbCrLf + vbCrLf
        .PrintNormal PTR_S_RECEIPT, "apples                  $20.00" + vbCrLf
        .PrintNormal PTR_S_RECEIPT, "grapes                  $30.00" + vbCrLf
        .PrintNormal PTR_S_RECEIPT, "bananas                 $40.00" + vbCrLf
        .PrintNormal PTR_S_RECEIPT, "lemons                  $50.00" + vbCrLf
        .PrintNormal PTR_S_RECEIPT, "oranges                 $60.00" + vbCrLf + vbCrLf
        .PrintNormal PTR_S_RECEIPT, ESC + "|bC" + "Tax excluded.          $200.00" + ESC + "|N" + vbCrLf
        .PrintNormal PTR_S_RECEIPT, ESC + "|uC" + "Tax  5.0%               $10.00" + ESC + "|N" + vbCrLf
        .PrintNormal PTR_S_RECEIPT, ESC + "|bC" + ESC + "|2C" + "Total   $210.00" + ESC + "|N" + vbCrLf
        .PrintNormal PTR_S_RECEIPT, "Customer's payment     $250.00" + vbCrLf
        .PrintNormal PTR_S_RECEIPT, "Change                  $40.00" + vbCrLf + vbCrLf

        .PrintNormal PTR_S_RECEIPT, ESC + "|fP"
    End With

End Sub


Private Sub cmdExit_Click()

    Unload Me

End Sub


Private Sub Form_Load()

    With OPOSPOSPrinter1
        .Open "Unit1"
        .ClaimDevice 1000
        .DeviceEnabled = True
       
        'Output by the high quality mode
        .RecLetterQuality = True
        'Register a bitmap
        .SetBitmap 1, PTR_S_RECEIPT, App.Path + "\Logo.bmp", PTR_BM_ASIS, PTR_BM_CENTER
    End With

End Sub


Private Sub Form_Unload(Cancel As Integer)

    With OPOSPOSPrinter1
        .DeviceEnabled = False
        .ReleaseDevice
        .Close
    End With

End Sub



-----------------------------------------------------------------------------------------------------------------------------------------

' Step 11  Use the EPSON original methods

Option Explicit

Private Type ITEMDATA
    Name As String
    Price As Long
End Type


Function GetErrorMsg() As String

    Dim BF As String

'Make messages on each event information
    Select Case OPOSPOSPrinter1.ResultCodeExtended
    Case OPOS_EPTR_COVER_OPEN
        BF = "Printer cover is open."
    Case OPOS_EPTR_JRN_EMPTY
        BF = "No jurnal paper."
    Case OPOS_EPTR_REC_EMPTY
        BF = "No receipt paper."
    Case OPOS_EPTR_SLP_EMPTY
        BF = "No slip form."
    Case Else
        BF = "ResultCode = " + CStr(OPOSPOSPrinter1.ResultCode) + vbCrLf + "ResultCodeExtended = " + CStr(OPOSPOSPrinter1.ResultCodeExtended)
    End Select

    GetErrorMsg = BF

End Function


Private Function SlpInsertion() As Boolean

    Dim MSG     As Long
    Dim SlpPrintable    As Long
    Dim pMSG    As String
    Dim bEndInsert  As Boolean
   
    'Insert sheet
    SlpPrintable = 1
    bEndInsert = False
   
    With OPOSPOSPrinter1
        While SlpPrintable
            .BeginInsertion 500
            'Check a sheet/Error check
            If (.ResultCode <> OPOS_SUCCESS) Then
                Select Case .ResultCode
                Case OPOS_E_TIMEOUT
                    pMSG = "Insert slip."
               
                Case OPOS_E_ILLEGAL
                    If (.SlpEmpty = True) Then
                        pMSG = "Remove slip."
                        bEndInsert = True
                        .EndInsertion
                    Else
                        pMSG = GetErrorMsg()
                        .BeginRemoval -1
                    End If
               
                Case Else
                    pMSG = GetErrorMsg()
                End Select
               
                MSG = MsgBox(pMSG, vbRetryCancel, "Print credit sales slip ")
                If bEndInsert = True Then
                    .EndInsertion
                    bEndInsert = False
                End If
                ' Cancel
                If (MSG = vbCancel) Then
                    SlpInsertion = False
                    Exit Function
                End If
            Else
                .EndInsertion
                pMSG = ""
                Select Case .ResultCode
                Case OPOS_E_EXTENDED
                    If .ResultCodeExtended = OPOS_EPTR_SLP_EMPTY Then
                        pMSG = "Insert slip."
                    End If
               
                Case OPOS_SUCCESS
                    'Slip is removed.
                    If .SlpNearEnd = True Then
                        .BeginRemoval -1
                        pMSG = "Insert slip."
                    'Cover is open.
                    ElseIf .CoverOpen = True Then
                        pMSG = "Close the cover"
                    Else
                        SlpPrintable = 0
                    End If
                   
                Case OPOS_E_ILLEGAL
                    If .CoverOpen = True And .SlpEmpty = True Then
                        pMSG = "Insert slip"
                        SlpPrintable = 0
                    Else
                        pMSG = "Insert slip"
                        .Close
                        .Open ("Unit1")
                        .ClaimDevice -1
                        .DeviceEnabled = True
                    End If
                End Select
                       
                If pMSG <> "" Then
                    MSG = MsgBox(pMSG, vbRetryCancel, "Print credit sales slip ")
                    If (MSG = vbCancel) Then
                        SlpInsertion = False
                        Exit Function
                    End If
                End If
            End If
        Wend
    End With

    SlpInsertion = True

End Function


Private Function SlpRemoval() As Boolean

    Dim pMSG    As String
    Dim MSG     As Long
    Dim RecPrintable As Long
   
    RecPrintable = 1
    With OPOSPOSPrinter1
        While RecPrintable
            .BeginRemoval 5000
            If (.ResultCode <> OPOS_E_TIMEOUT) Then
                RecPrintable = 0
            Else
                MSG = MsgBox("Remove slip", vbOKOnly + vbExclamation, "Print credit sales slip")
            End If
        Wend
        If (.ResultCode <> OPOS_E_ILLEGAL) Then
            RecPrintable = 1
            While RecPrintable
                .EndRemoval
                If (.ResultCode = OPOS_SUCCESS) Then
                    RecPrintable = 0
                Else
                    pMSG = GetErrorMsg()
                   
                    MSG = MsgBox(pMSG, vbRetryCancel + vbQuestion, "Print credit sales slip")
                    'Canceled
                    If (MSG = vbCancel) Then
                        SlpRemoval = False
                        Exit Function
                    End If
                End If
            Wend
        Else
            .EndRemoval
        End If
    End With

    SlpRemoval = True

End Function

Private Function MakePrintString(lRecLineChars As Long, sBuf As String, sPrice As String)
    Dim sValue As String
    If lRecLineChars < (Len(sBuf) + Len(sPrice)) Then
        sValue = sBuf + sPrice
    Else
        sValue = sBuf + Space(lRecLineChars - (Len(sBuf) + Len(sPrice))) + sPrice
    End If
   
    MakePrintString = sValue
End Function

Private Sub cmdPrint_Click()

    Dim bExit As Boolean
    Dim lValue As Long
    Dim i As Integer
    Dim idBuf(5) As ITEMDATA
    Dim ESC As String * 1
    Dim fDate As String
    Dim BcData  As String
    Dim sBuf As String
    Dim sPrice As String
    Dim sValue As String

    If OPOSPOSPrinter1.CapRecPresent = False Then
        MsgBox "Please insert a sheet", vbExclamation
        Exit Sub
    End If

' Initialization
    MousePointer = vbHourglass
    ESC = Chr(&H1B)
    fDate = Format(Now, "mmmm dd, yyyy  AM/PM h:mm")
    BcData = "4902720005074"
    bExit = False

' Make a data of the buying goods
    idBuf(0).Name = "apples":       idBuf(0).Price = 10
    idBuf(1).Name = "grapes":       idBuf(1).Price = 20
    idBuf(2).Name = "bananas":      idBuf(2).Price = 30
    idBuf(3).Name = "lemons":       idBuf(3).Price = 40
    idBuf(4).Name = "oranges":      idBuf(4).Price = 50

    With OPOSPOSPrinter1
        .TransactionPrint PTR_S_RECEIPT, PTR_TP_TRANSACTION
        If .ResultCode <> OPOS_SUCCESS Then
            MsgBox "Cannot use a POS Printer.", vbExclamation
            Exit Sub
        End If
       
        'Loop
        Do
            If .CapRecBitmap = True Then
                .PrintNormal PTR_S_RECEIPT, ESC + "|1B"
            End If
           
            .PrintNormal PTR_S_RECEIPT, ESC + "|N" + "123xxstreet,xxxcity,xxxxstate " + vbLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|rA" + "TEL 9999-99-9999   C#2" + vbLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|200uF"
            .PrintNormal PTR_S_RECEIPT, ESC + "|cA" + fDate + vbLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|500uF"
        'Print buying goods
            lValue = 0
            For i = LBound(idBuf) To UBound(idBuf) - 1
                If .ResultCode <> OPOS_SUCCESS Then Exit For
                sBuf = idBuf(i).Name
                lValue = lValue + idBuf(i).Price
                sPrice = Format(idBuf(i).Price, "$#.00")
                sValue = MakePrintString(.RecLineChars, sBuf, sPrice)
                .PrintNormal PTR_S_RECEIPT, sValue + vbLf
            Next
            .PrintNormal PTR_S_RECEIPT, ESC + "|200uF"
        'Print the total cost
            sBuf = "Before adding tax"
            sPrice = Format(lValue, "$#.00")
            sValue = MakePrintString(.RecLineChars, sBuf, sPrice)
            .PrintNormal PTR_S_RECEIPT, ESC + "|bC" + sValue + vbLf
            sBuf = "tax   5.0%"
            sPrice = Format(lValue * 0.05, "$#.00")
            sValue = MakePrintString(.RecLineChars, sBuf, sPrice)
            .PrintNormal PTR_S_RECEIPT, ESC + "|N" + ESC + "|uC" + sValue + vbLf
            sBuf = "total"
            sPrice = Format(lValue * 1.05, "$#.00")
            sValue = MakePrintString((.RecLineChars \ 2), sBuf, sPrice)
            .PrintNormal PTR_S_RECEIPT, ESC + "|N" + ESC + "|bC" + ESC + "|2C" + sValue + vbLf
            sBuf = "Customer's payment"
            sPrice = Format(200, "$#.00")
            sValue = MakePrintString(.RecLineChars, sBuf, sPrice)
            .PrintNormal PTR_S_RECEIPT, ESC + "|N" + sValue + vbLf
            sBuf = "Change"
            sPrice = Format(200 - lValue * 1.05, "$#.00")
            sValue = MakePrintString(.RecLineChars, sBuf, sPrice)
            .PrintNormal PTR_S_RECEIPT, sValue + vbLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|500uF"
           
            If .CapRecBarCode = True Then
                        .PrintBarCode PTR_S_RECEIPT, BcData, PTR_BCS_JAN13, 1000, .RecLineWidth, PTR_BC_CENTER, PTR_BC_TEXT_BELOW
            End If
           
            .PrintNormal PTR_S_RECEIPT, ESC + "|" + CStr(.RecLinesToPaperCut) + "lF"
            If .CapRecPapercut = True Then
                .CutPaper 100
            End If
           
            If .ResultCode = OPOS_SUCCESS Then Exit Do
           
        'When error occurs, display a message to ask the user whether retry or not.
            Select Case MsgBox("Fails to output to a printer." + vbCrLf + vbCrLf + "Retry?", vbAbortRetryIgnore + vbQuestion)
            Case vbAbort                    ' "Cancel"has been selected
                .ClearOutput
                bExit = True
                Exit Do
            Case vbRetry                    ' "Retry"has been selected.
                .ClearOutput
            Case vbIgnore                   ' "Ignore" has been selected.
                Exit Do
            End Select
        Loop
       
        If bExit = False Then               'Has it been canceled?
            ' Wait until device is 'OPOS_S_IDLE'
            While .State <> OPOS_S_IDLE
               
            Wend
            .TransactionPrint PTR_S_RECEIPT, PTR_TP_NORMAL
        End If
    End With

    MousePointer = vbDefault

End Sub

Private Sub cmdAsync_Click()

    Dim bExit As Boolean
    Dim lValue As Long
    Dim i As Integer
    Dim idBuf(5) As ITEMDATA
    Dim ESC As String * 1
    Dim fDate As String
    Dim BcData  As String
    Dim sBuf As String
    Dim sPrice As String
    Dim sValue As String

    If OPOSPOSPrinter1.CapRecPresent = False Then
        MsgBox "Please insert a sheet.", vbExclamation
        Exit Sub
    End If

' Initialization
    MousePointer = vbHourglass
    ESC = Chr(&H1B)
    fDate = Format(Now, "mmmm dd, yyyy  AM/PM h:mm")
    BcData = "4902720005074"
    bExit = False

' Make a data of the buying goods
    idBuf(0).Name = "apples":       idBuf(0).Price = 10
    idBuf(1).Name = "grapes":       idBuf(1).Price = 20
    idBuf(2).Name = "bananas":      idBuf(2).Price = 30
    idBuf(3).Name = "lemons":       idBuf(3).Price = 40
    idBuf(4).Name = "oranges":      idBuf(4).Price = 50

    With OPOSPOSPrinter1
        .AsyncMode = True
        .TransactionPrint PTR_S_RECEIPT, PTR_TP_TRANSACTION
        If .ResultCode <> OPOS_SUCCESS Then
            MsgBox "Cannot use a POS Printer.", vbExclamation
            Exit Sub
        End If
       
        'Loop
        Do
            If .CapRecBitmap = True Then
                .PrintNormal PTR_S_RECEIPT, ESC + "|1B"
            End If
           
            .PrintNormal PTR_S_RECEIPT, ESC + "|N" + "123xxstreet,xxxcity,xxxxstate " + vbLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|rA" + "TEL 9999-99-9999   C#2" + vbLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|200uF"
            .PrintNormal PTR_S_RECEIPT, ESC + "|cA" + fDate + vbLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|500uF"
        'Print buying goods
            lValue = 0
            For i = LBound(idBuf) To UBound(idBuf) - 1
                If .ResultCode <> OPOS_SUCCESS Then Exit For
                sBuf = idBuf(i).Name
                lValue = lValue + idBuf(i).Price
                sPrice = Format(idBuf(i).Price, "$#.00")
                sValue = MakePrintString(.RecLineChars, sBuf, sPrice)
                .PrintNormal PTR_S_RECEIPT, sValue + vbLf
            Next
            .PrintNormal PTR_S_RECEIPT, ESC + "|200uF"
        'Print the total cost
            sBuf = "Tax excluded."
            sPrice = Format(lValue, "$#.00")
            sValue = MakePrintString(.RecLineChars, sBuf, sPrice)
            .PrintNormal PTR_S_RECEIPT, ESC + "|bC" + sValue + vbLf
            sBuf = "Tax  5.0%"
            sPrice = Format(lValue * 0.05, "$#.00")
            sValue = MakePrintString(.RecLineChars, sBuf, sPrice)
            .PrintNormal PTR_S_RECEIPT, ESC + "|N" + ESC + "|uC" + sValue + vbLf
            sBuf = "Total"
            sPrice = Format(lValue * 1.05, "$#.00")
            sValue = MakePrintString((.RecLineChars \ 2), sBuf, sPrice)       'Because the width of characters of total is doubled, take this into consideration when computing.
            .PrintNormal PTR_S_RECEIPT, ESC + "|N" + ESC + "|bC" + ESC + "|2C" + sValue + vbLf
            sBuf = "Customer's payment"
            sPrice = Format(200, "$#.00")
            sValue = MakePrintString(.RecLineChars, sBuf, sPrice)
            .PrintNormal PTR_S_RECEIPT, ESC + "|N" + sValue + vbLf
            sBuf = "Change"
            sPrice = Format(200 - lValue * 1.05, "$#.00")
            sValue = MakePrintString(.RecLineChars, sBuf, sPrice)
            .PrintNormal PTR_S_RECEIPT, sValue + vbLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|500uF"
           
            If .CapRecBarCode = True Then
                        .PrintBarCode PTR_S_RECEIPT, BcData, PTR_BCS_JAN13, 1000, .RecLineWidth, PTR_BC_CENTER, PTR_BC_TEXT_BELOW
            End If
           
            .PrintNormal PTR_S_RECEIPT, ESC + "|" + CStr(.RecLinesToPaperCut) + "lF"
            If .CapRecPapercut = True Then
                .CutPaper 100
            End If
           
            If .ResultCode = OPOS_SUCCESS Then Exit Do
           
        'When error occurs, display a message to ask the user whether retry or not.
            Select Case MsgBox("Fails to output to a printer" + vbCrLf + vbCrLf + "RetryH", vbAbortRetryIgnore + vbQuestion)
            Case vbAbort                    ' "Cancel"has been selected
                .ClearOutput
                bExit = True
                Exit Do
            Case vbRetry                    ' "Retry" has been selected
                .ClearOutput
            Case vbIgnore                   ' "Ignore" has been selected
                Exit Do
            End Select
        Loop

        If bExit = False Then               'Has it been canceled?
            ' Wait until device is 'OPOS_S_IDLE'
            While .State <> OPOS_S_IDLE
               
            Wend
            .TransactionPrint PTR_S_RECEIPT, PTR_TP_NORMAL
        End If
        .AsyncMode = False
    End With

    MousePointer = vbDefault

End Sub

Private Sub cmdReceipt_Click()

    Dim bExit As Boolean
    Dim rcSpacing As Long
    Dim rcHeight As Long
    Dim ESC As String * 1
    Dim fDate As String

    If OPOSPOSPrinter1.CapRecPresent = False Then
        MsgBox "Please insert a sheet.", vbExclamation
        Exit Sub
    End If

'Check Rotate Function
    If OPOSPOSPrinter1.CapRecLeft90 = False Then
        MsgBox "This printer does not have a rotation printing function.", vbExclamation
        Exit Sub
    End If

' Initialization
    ESC = Chr(&H1B)
    bExit = False
    fDate = Format(Now, "mmmm dd, yyyy  AM/PM h:mm")

    With OPOSPOSPrinter1
        'Batch processing mode
        .TransactionPrint PTR_S_RECEIPT, PTR_TP_TRANSACTION
        If .ResultCode <> OPOS_SUCCESS Then
            MsgBox "Cannot use a POS Printer.", vbExclamation
            Exit Sub
        End If
        'Rotate 90
        .RotatePrint PTR_S_RECEIPT, PTR_RP_LEFT90

        'Loop
        Do
            rcSpacing = .RecLineSpacing                'Keep the default line spacing
            rcHeight = .RecLineHeight                  'Keep the default line height
           
            'Printing process
            .PrintNormal PTR_S_RECEIPT, ESC + "|4C" + ESC + "|bC" + "   Receipt     "
            .PrintNormal PTR_S_RECEIPT, ESC + "|3C" + ESC + "|2uC" + "       Mr. Brawn" + vbCrLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|2uC" + "                                                  " + vbCrLf + vbCrLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|2uC" + ESC + "|3C" + "        Total payment              $" + ESC + "|4C" + "21.00  " + vbCrLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|1C" + vbCrLf
            .PrintNormal PTR_S_RECEIPT, fDate + " Received" + vbCrLf + vbCrLf
            .RecLineHeight = 24
            .RecLineSpacing = .RecLineHeight
            .PrintNormal PTR_S_RECEIPT, ESC + "|uC" + " Details               " + vbCrLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|1C" + "                          " + ESC + "|2C" + "OPOS Store" + vbCrLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|uC" + " Tax excluded    $20.00" + vbCrLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|1C" + "                          " + ESC + "|bC" + "Zip code 999-9999" + vbCrLf
            .PrintNormal PTR_S_RECEIPT, ESC + "|uC" + " Tax(5%)        $1.00" + ESC + "|N" + "    Phone#(9999)99-9998" + vbCrLf

            'When outputting normally,breakout of the loop.
            If .ResultCode = OPOS_SUCCESS Then Exit Do
            'When error occurs, display a message to ask the user whether retry or not.
            Select Case MsgBox("Fails to output to a printer." + vbCrLf + vbCrLf + "Retry?", vbAbortRetryIgnore + vbQuestion)
            Case vbAbort                    ' "Cancel"has been selected
                'Clear all the buffer, and exit.
                .ClearOutput
                bExit = True
                Exit Do
            Case vbRetry                    ' "Retry"has been selected.
                'Clear all the buffer data, and retry.
                .ClearOutput
            Case vbIgnore                   '"Ignore" has been selected.
                Exit Do
            End Select
        Loop

        .RotatePrint PTR_S_RECEIPT, PTR_RP_NORMAL

        If bExit = False Then
            If (.ResultCode = OPOS_SUCCESS) Then
                .PrintNormal PTR_S_RECEIPT, ESC + "|" + CStr(.RecLinesToPaperCut) + "lF"
                If .CapRecPapercut = True Then          'ut function, or not.
                    .CutPaper 100
                End If
            Else
                MsgBox "Cannot use a POS Printer" + vbCrLf + "ResultCode = " + CStr(.ResultCode) + vbCrLf + "ResultCodeExtended = " + CStr(.ResultCodeExtended), 0, "—ÌŽû‘ˆóŽš"
                .ClearOutput
            End If
        End If

        ' Wait until device is 'OPOS_S_IDLE'
        While .State <> OPOS_S_IDLE
        Wend
        'Print all the buffer data, and exit the batch processing mode.
        .TransactionPrint PTR_S_RECEIPT, PTR_TP_NORMAL

        .RecLineSpacing = rcSpacing
        .RecLineHeight = rcHeight
    End With

End Sub

Private Sub cmdPrintSales_Click()

    Dim RecNo   As Long
    Dim ESC As String * 1
    Dim fDate   As String
    Dim fTime   As String
    Dim fRecNo  As String
    Dim fName   As String
    Dim fSpace  As String
    Dim OutputData As String

'Request for inserting a slip
    If SlpInsertion() = False Then
        Exit Sub
    End If

' Initialization
    MousePointer = vbHourglass
    ESC = Chr(&H1B)
    fDate = Format(Date, "mmmm dd, yyyy")       'System date
    fTime = Format(Time, "h:mm")                'System time
    RecNo = 1                                   'Register No.
    fRecNo = Format(RecNo, "  0000")
    fName = "ABCDEF"                             'Casher No.
    If OPOSPOSPrinter1.SlpLineChars > 33 Then
        fSpace = Space(OPOSPOSPrinter1.SlpLineChars - 33)    'Left space
    Else
        fSpace = ""
    End If
   
    ' Print data
    OutputData = vbCrLf + fSpace + "Print credit card sales slip" + vbCrLf
    OutputData = OutputData + ESC + "|1lF"
    OutputData = OutputData + fSpace + "        SEIKO EPSON Corp." + vbCrLf
    OutputData = OutputData + fSpace + "Thank you for coming to our shop!" + vbCrLf
    OutputData = OutputData + ESC + "|1lF"
    OutputData = OutputData + fSpace + "Date " + fDate + vbCrLf
    OutputData = OutputData + fSpace + "Time      " + fTime + "Casher   " + fName + vbCrLf
    OutputData = OutputData + fSpace + "Number of the register" + fRecNo + vbCrLf
    OutputData = OutputData + ESC + "|N" + ESC + "|1lF"
    OutputData = OutputData + fSpace + "Details                      cost" + vbCrLf
    OutputData = OutputData + fSpace + "Cardigan                 $ 100.00" + vbCrLf
    OutputData = OutputData + fSpace + "Shoes                     $ 70.00" + vbCrLf
    OutputData = OutputData + fSpace + "Hat                       $ 30.00" + vbCrLf
    OutputData = OutputData + fSpace + "Bag                      $ 150.00" + vbCrLf
    OutputData = OutputData + fSpace + "        Excluded tax     $ 350.00" + vbCrLf
    OutputData = OutputData + fSpace + "        Tax(5%)           $ 17.50" + vbCrLf
    OutputData = OutputData + fSpace + "        -------------------------" + vbCrLf
    OutputData = OutputData + fSpace + ESC + "|2C     Total" + ESC + "|1C     $ 367.50" + vbCrLf
    OutputData = OutputData + ESC + "|1lF"
    OutputData = OutputData + fSpace + "Company name   EPSON-CARD" + vbCrLf
    OutputData = OutputData + fSpace + "Membership No. XXXXXXXXXXXXXXXX" + vbCrLf
    OutputData = OutputData + fSpace + "Valid date     12/05" + vbCrLf
    OutputData = OutputData + fSpace + "Handling No.   9999 - 999999" + vbCrLf
    OutputData = OutputData + fSpace + "Approval No.   99" + vbCrLf
    OutputData = OutputData + ESC + "|1lF"
    OutputData = OutputData + fSpace + "Signature" + vbCrLf
    ' Printing process
    OPOSPOSPrinter1.PrintNormal PTR_S_SLIP, OutputData

' Clean up
    MousePointer = vbDefault

    'Remove the slip at the slip station.
    If SlpRemoval() = False Then
        'Fail
    End If

End Sub


' <<< Step 11 >>>
'Control the initial position of the printer using the Direct IO.
'Useful for printing neatly.
'
Private Sub cmdShiftPrint_Click()

'   ESC/POS command
'       ESC = n             n = 1
'           Explanation: Printer selection command
'
'       ESC $ nL nH         nL, nH = Voluntary nunber among 0`255
'           Explanation: Move the printing position to nL + nH~256 from the left side.

    Dim pData As Long
    Dim pString As String

    pData = 0
' Connect a printer directly.(Support Hydra connection)
    pString = Chr(&H1B) + "=" + Chr(1)
' Move the printing position to nL + nH~256 from the left side.
    pString = pString + Chr(&H1B) + "$" + Chr(100) + Chr(0)
    OPOSPOSPrinter1.DirectIO PTR_DI_OUTPUT_NORMAL, pData, pString

' Test printing
    OPOSPOSPrinter1.PrintNormal PTR_S_RECEIPT, "DirectIO" + vbCrLf

End Sub

' <<< Step 11 >>>
'In using Direct IO, use the NVRAM to print a bitmap .
'
Private Sub cmdNVRAM_Click()

    Dim pData As Long
    Dim pString As String

' Needed to register the bitmap before using it.
' TMLlogo can be start up individually from the Device Specific Settings of the SetupPOS.

    pData = 1           'Number of the registered bitmap.
    pString = ""
    OPOSPOSPrinter1.DirectIO PTR_DI_PRINT_FLASH_BITMAP, pData, pString

End Sub

' <<< Step 11 >>>
Private Sub cmdMaintenance_Click(Index As Integer)

    Dim lCommand As Long
    Dim lCounterNum As Long
    Dim strCounter As String

    Select Case Combo1.ListIndex
    Case 0                      'Advance paper(number of lines): Slip
        lCounterNum = &HA
    Case 1                      'Total number of printing characters: Slip(Front)
        lCounterNum = &HB
    Case 2                      'Slip paper feed in terms of number of lines:Roled sheet
        lCounterNum = &H14
    Case 3                      'Numbers of strike on sheet: Roled sheet
        lCounterNum = &H15
    Case 4                      'Number of the checks read
        lCounterNum = &H3C
    Case 5                      'Working time of the printer
        lCounterNum = &H46
    End Select

    Select Case Index
    Case 0                  'Reset
        lCommand = PTR_DI_RESET_MAINTENANCE_COUNTER
    Case 1                  'Get
        lCommand = PTR_DI_GET_MAINTENANCE_COUNTER
    Case 2                  'Cumulative
        lCommand = PTR_DI_GET_MAINTENANCE_COUNTER
        lCounterNum = lCounterNum Or &H80
    End Select

    'In using the DirectIO method, use functions of the maintenance counter.
    If OPOSPOSPrinter1.DirectIO(lCommand, lCounterNum, strCounter) = OPOS_SUCCESS Then
        If Index = 0 Then
            Text1.Text = "Success."
        Else
            Text1.Text = strCounter
        End If
    Else
        Text1.Text = "Error."
    End If

End Sub

Private Sub OPOSPOSPrinter1_ErrorEvent(ByVal ResultCode As Long, ByVal ResultCodeExtended As Long, ByVal ErrorLocus As Long, pErrorResponse As Long)

    MsgBox "Printer Error." + vbCrLf + vbCrLf + "ResultCode = " + CStr(ResultCode) + vbCrLf + "ResultCodeExtended = " + CStr(ResultCodeExtended), vbInformation

End Sub

Private Sub OPOSPOSPrinter1_OutputCompleteEvent(ByVal OutputID As Long)

'Notify that printing is completed when it is asnchronous.
    MsgBox "Complete printing", vbInformation

End Sub


Private Sub OPOSPOSPrinter1_StatusUpdateEvent(ByVal Data As Long)
'When there is a change of the status on the printer, the event is fired.

    Dim bRecEnb As Boolean

    bRecEnb = True

'Make messages for the each event information.
    Select Case Data
    Case PTR_SUE_COVER_OPEN         'Printer cover is open.
        bRecEnb = False
    Case PTR_SUE_REC_EMPTY          'No receipt paper.
        bRecEnb = False
    End Select

    cmdPrint.Enabled = bRecEnb
    cmdAsync.Enabled = bRecEnb
    cmdReceipt.Enabled = bRecEnb
    cmdPrintSales.Enabled = bRecEnb

End Sub

Private Sub cmdExit_Click()

    Unload Me

End Sub

Private Sub Form_Load()

    With OPOSPOSPrinter1
        .Open "Unit1"
        If .ResultCode <> OPOS_SUCCESS Then
            MsgBox "Fails to open the device."
            GoTo LoadError
        End If
       
        .ClaimDevice 1000
        If .ResultCode <> OPOS_SUCCESS Then
            MsgBox "Fails to claim the device."
            GoTo LoadError
        End If
       
        .DeviceEnabled = True
        If .ResultCode <> OPOS_SUCCESS Then
            MsgBox "Disable to use the device."
            GoTo LoadError
        End If
       
        .MapMode = PTR_MM_METRIC
        .RecLetterQuality = True
       
        If .CapRecBitmap = True Then
            .SetBitmap 1, PTR_S_RECEIPT, App.Path + "\Logo.bmp", .RecLineWidth / 2, PTR_BM_CENTER
        End If
        If (.CapRecLeft90 = False) Or (.CapRecRight90 = False) Then
            cmdReceipt.Enabled = False
        End If
        If (.CapSlpPresent = False) Or (.CapSlpFullslip = False) Then
            cmdPrintSales.Enabled = False
        End If
    End With

    Combo1.ListIndex = 0
    Exit Sub

' Error disposal
LoadError:
    Dim OBJ As Object
    ' All disable to print button.
    For Each OBJ In Me
        If OBJ.Name <> "OPOSPOSPrinter1" Then
            OBJ.Enabled = False
        End If
    Next
    ' Enable to [Close] button only.
    cmdExit.Enabled = True

End Sub

Private Sub Form_Unload(Cancel As Integer)

    With OPOSPOSPrinter1
        .DeviceEnabled = False
        .ReleaseDevice
        .Close
    End With

End Sub

with regards,
padmaja.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now