Question

Locked

sending command to slip printer through vb code

By amit.jaiswal ·
hello i want to send some specific command to printer,
such as Release Paper from printer after printing completes....

i am using following commands...

Open "LPT1:" For Output As #1


Print #1, "LINE Number1"
Print #1, "LINE Number2"
Print #1, "LINE Number3"
Print #1, "LINE Number4"
Print #1, "LINE Number5"
Print #1, "LINE Number6"
Print #1, "LINE Number7"
Print #1, "LINE Number8"

Print #1, Chr$(27) & Chr$(113)
Close #1

but it is not working,so if any body know the solution then plz reply me.......

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

RE: sending command to slip printer through vb code

by ian.f.scott3G In reply to sending command to slip p ...

What happens when you execute your code? Anything? Nothing?

Have you read the programmer's manual for your printer thoroughly?

From the limited involvement I have had writing print drivers for slip printers, this is not a trivial exercise. Some printers have quite a complex protocol where you send a command string and receive some status information back from the printer. If only it was as simple printing to a matrix printer or inkjet printer!!

I would do a Web search looking for some sample code for you printer to use as a starting point.

Collapse -

Sending Control Characters to Text File

by unni_kcpm In reply to sending command to slip p ...

Dear Mr.Amit,

Here below is the code written and used
by self to generate a text file. How to
use it and send to printer hope you know.

Quote :
*******

'I have kept the report path in a table
savepath = rsReport!Rptpath
fname1 = savepath & a
b= "Report Heading"
ffopen1 = FreeFile
Open fname1 For Output As #ffopen1

Line1 = Chr(27) & Chr(14) & Space(3) & b & Chr(20) & Chr(27)
Print #1, Line1
Print #1, ""
'Line1 = Space(13) & Format(Startdtpick.Value, "DD/MM/YYYY") & " To " & Format(Enddtpick.Value, "DD/MM/YYYY")
Line1 = Space(3) & "Period : " & Format(Startdtpick.Value, "MMM-DD-YYYY") & " To " & Format(Enddtpick.Value, "MMM-DD-YYYY")
Print #1, Line1
Print #1, Space(7) & "(Sub Heading)" & Chr(27) & Chr(15)
Print #1, ""
Print #1, "======================================================================================================="
Line1 = "Report Columns here "
Print #1, Line1
Print #1, "======================================================================================================="
Print #1, ""

Dim n As Double
n = 0
With rs
If Not (rs.EOF And rs.BOF) Then rs.MoveFirst
While Not .EOF
Dim s
s = Space(6)
n = n + 1
tf = rs!md2 + rs!mr2 + rs!mot1
ff = (rs!md4 + rs!md5 + rs!mr5 + rs!mot2)
Line1 = Format(n, "#00") & ". " & Space(5) & !secname & Space(40 - Len(!secname)) & IIf(IsNull(Format(rs!md2, "#0")), 0, Format(rs!md2, "#0")) & Space(5) & IIf(IsNull(Format(rs!md4, "#0")), 0, Format(rs!md4, "#0")) & Space(5) & IIf(IsNull(Format(rs!md5, "#0")), 0, Format(rs!md5, "#0")) & Space(5) & IIf(IsNull(Format(rs!mr2, "#0")), 0, Format(rs!mr2, "#0")) & Space(5) & IIf(IsNull(Format(rs!mr5, "#0")), 0, Format(rs!mr5, "#0")) & Space(5) & IIf(IsNull(Format(rs!mot1, "#0")), 0, Format(rs!mot1, "#0")) & Space(5) & IIf(IsNull(Format(rs!mot2, "#0")), 0, Format(rs!mot2, "#0")) & Space(6) & IIf(IsNull(Format(tf, "#0")), 0, Format(tf, "#0")) & Space(5) & IIf(IsNull(Format(ff, "#0")), 0, Format(ff, "#0"))
tf = 0
ff = 0
tmd2 = tmd2 + rs!md2
tmd4 = tmd4 + rs!md4
tmd5 = tmd5 + rs!md5
tmr2 = tmr2 + rs!mr2
tmr5 = tmr5 + rs!mr5
tmot1 = tmot1 + rs!mot1
tmot2 = tmot2 + rs!mot2
Print #1, Line1
.MoveNext
Wend
ttf = tmd2 + tmr2 + tmot1
fff = (tmd4 + tmd5 + tmr5 + tmot2)
Print #1, ""
Print #1, "======================================================================================================="
Line1 = " G R A N D T O T A L " & Space(22) & IIf(IsNull(Format(tmd2, "#0")), 0, Format(tmd2, "#0")) & Space(5) & IIf(IsNull(Format(tmd4, "#0")), 0, Format(tmd4, "#0")) & Space(5) & IIf(IsNull(Format(tmd5, "#0")), 0, Format(tmd5, "#0")) & Space(5) & IIf(IsNull(Format(tmr2, "#0")), 0, Format(tmr2, "#0")) & Space(5) & IIf(IsNull(Format(tmr5, "#0")), 0, Format(tmr5, "#0")) & Space(5) & IIf(IsNull(Format(tmot1, "#0")), 0, Format(tmot1, "#0")) & Space(5) & IIf(IsNull(Format(tmot2, "#0")), 0, Format(tmot2, "#0")) & Space(5) & IIf(IsNull(Format(ttf, "#0")), 0, Format(ttf, "#0")) & Space(5) & IIf(IsNull(Format(fff, "#0")), 0, Format(fff, "#"))
Print #1, Line1
Print #1, "======================================================================================================="
Dim teu
teu = ttf + ((fff) * 2)
Print #1, "Total : " & Format(teu, "###0") & " Teus."
Print #1, "" // Blank Line
Print #1, "" // Blank Line
Print #1, "Generated on : " & Format(Date, "MMM-DD-YYYY") & Space(2) & Format(Time, "HH:MM:SS")
Print #1, ""
Print #1, "End of Report : " & st
Print #1, Chr(27) & Chr(14)
End With
Close ffopen1
rs.Close

Unquote :
*********

Trust above helps.

Rgds
Menon, Cochin.

Collapse -

Applicable to DOT Matrix printers exp. EPSON

by unni_kcpm In reply to Sending Control Character ...

This code can be used to generate a text file which can be printed to a DOT MATRIX printer. Tested on EPSON L series printer.

Collapse -

Use the printer object in VB

by gwl In reply to sending command to slip p ...

VB has an object called the 'printer' object.
If you will just enter Printer. and then VB will expose all of the various parameters for you. This object uses the current default Printer defined by Windows.
For Example:
Printer.bold = true (will print text in bold)
Printer.font.size = 14 (will print text in font size 14)
Printer.NewPage will eject the print to a new page
Printer.EndDoc will eject the last page and clear the printer object.

After you set the parameters you need you can print to the default windows printer by using the .print properties:

Printer.print "now is the time"

You can also define X and Y coordinates where the print will occure by using the .CurrentX and .CurrentY properties such as:
printer.currentx = 1.5
printer.currenty = 2.0

Collapse -

'printer' object.

by prasann.be In reply to Use the printer object in ...

i am using Visual Basic 6 version i didn't get printer object

Collapse -

Formfeed

by Adagroup In reply to sending command to slip p ...

Hi Amit,
Send the formfeed character [Chr(12)] after your printing is finished.

Note that you MUST set the paper size IN PRINTER to correct actual paper size.

Regds
Inderjeet S SOdhi
IT Consultant, E-Security & S/W Solution Provider,
WAP/Web Developer and Beta-Tester.

www.inderjeetsodhi.com

Collapse -

re sending command to slip printer through vb code

by rieda In reply to sending command to slip p ...

are u talking about cutting the paper

Back to Peripheral Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums