|
-
Sep 6th, 2000, 08:09 AM
#1
Thread Starter
Addicted Member
Hey,
I just want to print a character to the printer. But it doesnt print or do anything. i want to print the chr$(28) key but nothing happens. I need to print this value as it opens a particular cash draw.. I have tried typing printer.print chr$(28)
printer.enddoc
am i doing something wrong? Please help me!
-
Sep 6th, 2000, 09:09 AM
#2
I had a similar problem with a cash drawer once, and it turned out that the drawer was configured wrong. Make sure you can open it by sending the ascii 28 by doing the following:
Go to a command prompt and open a new file with the MS-DOS editor. Press Control-P and while still holding the control key press the pipe (|) key - for some reason this is 1Ch. Save the file and then
Code:
copy myfile.txt lpt1
Make sure the drawer pops open.
John
-
Sep 7th, 2000, 11:20 PM
#3
Thread Starter
Addicted Member
printing
that way works but i dont want to have to shell to dos and do it each time. is there any code which can pop it open without shelling to a dos shell?
please reply.
-
Sep 8th, 2000, 11:20 AM
#4
This should open your cash drawer with ascii 28. (It opens mine when I change it to ascii 7) This is the code from the MSDN to write directly to the printer.
Code:
Option Explicit
Private Type DOCINFO
pDocName As String
pOutputFile As String
pDatatype As String
End Type
Private Declare Function ClosePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function EndDocPrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function EndPagePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function OpenPrinter Lib "winspool.drv" Alias _
"OpenPrinterA" (ByVal pPrinterName As String, phPrinter As Long, _
ByVal pDefault As Long) As Long
Private Declare Function StartDocPrinter Lib "winspool.drv" Alias _
"StartDocPrinterA" (ByVal hPrinter As Long, ByVal Level As Long, _
pDocInfo As DOCINFO) As Long
Private Declare Function StartPagePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long) As Long
Private Declare Function WritePrinter Lib "winspool.drv" (ByVal _
hPrinter As Long, pBuf As Any, ByVal cdBuf As Long, _
pcWritten As Long) As Long
Private Sub Command1_Click()
Dim lhPrinter As Long
Dim lReturn As Long
Dim lpcWritten As Long
Dim lDoc As Long
Dim sWrittenData As String
Dim MyDocInfo As DOCINFO
lReturn = OpenPrinter("HP LaserJet 1100", lhPrinter, 0)
If lReturn = 0 Then
MsgBox "The Printer Name you typed wasn't recognized."
Exit Sub
End If
MyDocInfo.pDocName = "AAAAAA"
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Call StartPagePrinter(lhPrinter)
sWrittenData = Chr$(28) & vbFormFeed
lReturn = WritePrinter(lhPrinter, ByVal sWrittenData, _
Len(sWrittenData), lpcWritten)
lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|