I just want to share with you the code that I have found on the internet on how to open a Cash Drawer using VB.NET.
I am in no way claim this code as my own work. I want to share this with you because there’s a lot of question on the internet on how to open a Cash Drawer on VB.NET.
The code will simply open the cash drawer using either the LPT port or COM port.
Use the following code and test it if it will work on the brand of your cash drawer.
Private Sub OpenCashDrawer()
'Use this code if you are using LPT Port
FileOpen(1, "c:\escapes.txt", OpenMode.Output)
FileClose(1)
Shell("print /d:lpt1 c:\escapes.txt", vbNormalFocus)
'Use this code if you are using COM Port
FileOpen(1, AppDomain.CurrentDomain.BaseDirectory & "open.txt", OpenMode.Output)
FileClose(1)
Shell("print /d:com1 open.txt", AppWinStyle.Hide)
End Sub