In this post i'll show you how to fire a USB/Serial cash drawer trigger.
These are little boxes that go between the computer and a cash drawer to open it when there is no receipt printer (most support the firing of it for you).
Some background: The device installs itself as a virtual COM port, this means if you look under device manager and com ports you should see what value is given to it, you can hard code the port but I use a simple method to grab it
***DISCLAIMER*** this assumes you have only 1 COM device installed on your machine
Code:
Public Sub Opencashdrawer()
If IsNothing(My.Computer.Ports.SerialPortNames(0).ToString) Then
Else
Dim p As String = My.Computer.Ports.SerialPortNames(0).ToString
Dim sp As New SerialPort
sp.PortName = p
sp.Open()
sp.Write("o")
sp.Close()
sp.Dispose()
End If
End Sub
As you can see in the code we grab the first entry in the list of port names then open a serialport. To trigger the device you just need to write any old data to it, here I have just sent an o
To use the sub place it where any form can see it and call Opencashdrawer
Hope this helps someone