Open cash drawer connected to Epson receipt printer - Visual Basic .Net

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This is a tutorial on how to pop open a cash drawer that is connected to epson cash drawer.

First you need to have your espon printer driver already installed. You can check if your epson receipt printer properly installed by going to Devices and Printers in your Control Panel:
check if epson printer installed

Right click on the printer icon, then click on Printer Properties, then click on Print Test Page

If the printer is working then procceed to the following.

Now you need to add EpsonStatusAPI.dll to your project. You should get EpsonStatusAPI.dll when you download the epson pos driver from Epson Pos Driver

In your Visual Basic application, go to Project, Add Reference, Browse Tab and search for EpsonStatusAPI.dll and click Ok

Add a button to your project:

Now go to the code page and add the following code above Public Class Form1 line:

    Imports com.epson.pos.driver
	Imports System.Drawing.Printing

Then add the following declarations below Public Class Form1 line:

    Dim m_objAPI As New StatusAPI
    Private WithEvents pdPrint As PrintDocument
    
    Dim PRINTER_NAME As String = "EPSON TM-T88IV Receipt" 'Change to your printer name
    

Add the following methods:

    Public Sub CommandDrawer()
        Try
            If m_objAPI.OpenMonPrinter(OpenType.TYPE_PRINTER, PRINTER_NAME) = ErrorCode.SUCCESS Then
                If m_objAPI.SetStatusBack() = ErrorCode.SUCCESS Then
                    pdPrint = New PrintDocument
                    pdPrint.PrinterSettings.PrinterName = PRINTER_NAME
                    OpenDrawer()
                Else
                End If
                If Not m_objAPI.CloseMonPrinter = ErrorCode.SUCCESS Then
                End If
            Else
            End If
        Catch ex As Exception
        End Try
    End Sub
    Private Sub OpenDrawer()
        Try
            If Not m_objAPI.OpenDrawer(Drawer.EPS_BI_DRAWER_1, Pulse.EPS_BI_PULSE_100) = ErrorCode.SUCCESS Then
            End If
        Catch ex As Exception
        End Try
    End Sub

Then finally the button click event code:

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        CommandDrawer()
    End Sub
    


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.