[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 490
  • Last Modified:

How to send a command to printer port to print reciept for a POS system?

my company is developing a POS software for our own use. Can anyone tell  me how to send a command to com port to trigger the receipt printer to print the receipt? i need an example as well, tks

i'm not sure bout the difficulty in doing so, guess i will just put on 100 pts, and will increase the pts appropriately upon request.
0
zeBes
Asked:
zeBes
  • 2
  • 2
1 Solution
 
ositearCommented:
You need to configure the printer in windows like any other printer, and let´s name it "REC". Try a print test page to check it´s been propertly configured.


then on VB:

Dim X As Printer

For Each X In Printers
        If Trim(X.DeviceName) = "REC" Then
            Set Printer = X
            Exit For
        End If
Next


Then you can go like
printer.fontname
printer.fontsize
and ...
printer.print "INVOICE NUMBER" & invoice_number

the printer.print prints a single text line on the device (there is no need for vbNewLine's)

with printer.enddoc you send de end of page command to the printer

Hope that helps
0
 
zeBesAuthor Commented:
hmm, but we need to send a command, says "M + D + Lblah", to the com port to 'inform' the printer that we are going to print sth to the printer..
understand? hmm... well, if i confuse you, let me know, i tried to gather more info.

tks
0
 
ositearCommented:
What kind of command are you talking about? Control commands?
Most of them can be send using "printer" object
printer.Fontbold = true
printer.print "This is a bold text"
printer.fontbold = false

Or maby you want to send them as raw text, remember that control commands are ascii characters, so you can send them INSITE your data using chr() function:

printer.print chr(10) & "this is a text after a line feed"

since the 10 (hex 0A) is the line feed command.


Some other control codes are:
TAB <09>
CRLF <0D>
ESC <1B>
Page feed <0C>
Line Feed <0A>
NUL <00>

Hope this helps.
0
 
zeBesAuthor Commented:
sorry for the late respond. tks for your help ;)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now