How to Open Cash Drawer using VB.NET

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() Dim intFileNo As Integer = FreeFile() 'Use this code if you are using LPT Port FileOpen(1, "c:\escapes.txt", OpenMode.Output) PrintLine(1, Chr(27) & "p" & Chr(0) & Chr(25) & Chr(250)) 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) PrintLine(1, Chr(27) & Chr(112) & Chr(0) & Chr(25) & Chr(250)) FileClose(1) Shell("print /d:com1 open.txt", AppWinStyle.Hide) End Sub

Comments

Submitted byAnonymous (not verified)on Mon, 07/04/2011 - 23:33

Hi, Thanks for sharing What would i have to change in this code for vb6 Thanks a lot
Submitted byAnonymous (not verified)on Fri, 07/08/2011 - 09:59

tnx for the share. . . this is just what i search for . . . thank you.
Submitted byAnonymous (not verified)on Sat, 08/06/2011 - 04:14

What do I have to do to this code to open a cash drawer if the POS printer is connected trough a USB port? 'Use this code if you are using COM Port FileOpen(1, AppDomain.CurrentDomain.BaseDirectory & "open.txt", OpenMode.Output) PrintLine(1, Chr(27) & Chr(112) & Chr(0) & Chr(25) & Chr(250)) FileClose(1) Shell("print /d:com1 open.txt", AppWinStyle.Hide)
Submitted bybc3 (not verified)on Wed, 02/29/2012 - 01:20

thank you very much! ur post help me a lot :)
Submitted bySanjeev (not verified)on Tue, 07/10/2012 - 23:10

Hi I can't find what inside escapes.txt and open.txt files. Can u post it please? Thanks.
Submitted byKhusrao Adil Khan (not verified)on Thu, 06/28/2018 - 15:38

Can any one please help me to know what is Open.txt or escape.txt
what written inside them. where it should be located.what is the purpose of those.
i found above code on lot of places but no body ever explain about opent.txt and escape.txt.
can any body help.

Add new comment