How to Open Cash Drawer using VB.NET
Friday, July 1, 2011 - 11:22
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
Convert to vb6
Hi,
Thanks for sharing
What would i have to change in this code for vb6
Thanks a lot
Great!
tnx for the share. . .
this is just what i search for . . .
thank you.
How to do it with USB POS printer.
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)
hi can u post what inside in
hi
can u post what inside in the escapes.txt and open.txt files?
thank you!
thank you very much! ur post help me a lot :)
Add new comment