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

Posted on 2005-04-22
Last Modified: 2010-05-02
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.
Question by:zeBes
    LVL 1

    Expert Comment

    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

    Then you can go like
    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

    Author Comment

    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.

    LVL 1

    Accepted Solution

    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.

    Author Comment

    sorry for the late respond. tks for your help ;)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now