
- Forum
- Programming Talk
- Microsoft .NET
- printing POS receipt in vb.net
printing POS receipt in vb.net
This is a discussion on printing POS receipt in vb.net within the Microsoft .NET forums, part of the Programming Talk category; Hi All, I actually need help with printing reciepts using thermal printer the situation is i have a touch screen ...
-
05-16-2008, 01:08 PM #1
- Join Date
- May 2008
- Answers
- 1
printing POS receipt in vb.net
Hi All,
I actually need help with printing reciepts using thermal printer
the situation is i have a touch screen machine that generates Tokens
now when the user clicks on the button his token is printed out with the token no on it(the token no
is generated from an mysql database) with the company logo displayed on top and few texts underneath
i am using vb.net to create the application but i donno how to print the token receipt
the machine has epson javapos driver already installed in it
can some one please help me with it
Thanks a lot in advance
-
how to print receipt by using pos printer using VB.net
In RMS some times we need to print receipt like Sales Receipt, Gift Receipt etc by POS printer. Before printing the receipt we need to make a string with using escape sequences, that escape sequences recognized by the printer. If an escape sequence specifies an operation that is not supported by the printer station, it is ignored.
Following is the code snippet for printing Gift Receipt by EPSON TM-T88IVP Printer.
************ VB Code *********
Public Sub GiftReceipt()
Try
Dim displayString As String
Dim ESC As String = Chr(&H1B)
displayString = ESC + "!" + Chr(1) + ESC + "|cA" + "Store Name" + ESC + "|1lF"
displayString += ESC + "|cA" + "Store Address" + ESC + "|1lF"
displayString += ESC + "|2C" + ESC + "|cA" + ESC + "|bC" + "Gift Receipt" + ESC + "|1lF" + ESC + "|1lF"
displayString += ESC + "|N" + ESC + "!" + Chr(1) + " Transaction #: " + vbTab.ToString() + "105" + ESC + "|1lF"
displayString += " Date: " + Date.Today() + vbTab.ToString() + "Time: "
displayString += DateAndTime.Now().ToLongTimeString() + ESC + "|1lF"
displayString += " Cashier: " + CStr(_currSess.Cashier.Number) + vbTab.ToString() + "Register: " + CStr(_currSess.Register.Number) + ESC + "|1lF" + ESC + "|1lF"
displayString += ESC + "|2uC" + " Item Description Quantity" + ESC + "|N" + ESC + "!" + Chr(1) + ESC + "|1lF" + ESC + "|1lF" + " "
'Iterate loop for each row of the Data Set.
For k As Integer = 0 To TransactionSet1.TransactionEntry.Rows.Count - 1
'Checking for each row which has selected in DataGrid item.
If CType(dgTransactionList.Item(k, 0), System.String) = "True" Then
'Get the Item value from selected row.
Dim item As String = dgTransactionList.Item(k, 1).ToString()
Dim itemValue As String = String.Empty
If item.Length > 11 Then
'if Item length is greater then 11, then take substring of item 0 to 11.
item = item.Substring(0, 11)
Else
'Adding " " in Item string until length 11.
While item.Length <= 11
item += " "
End While
End If
displayString += item + vbTab.ToString()
Dim desc As String = dgTransactionList.Item(k, 2).ToString()
Dim descValue As String = String.Empty
If desc.Length > 20 Then
'If Description length is greater then 20, then take substring of item 0 to 20.
desc = desc.Substring(0, 20)
Else
While desc.Length <= 20
'Adding " " in Description string until length 20.
desc += " "
End While
End If
displayString += desc + vbTab.ToString()
Dim qnty As String = dgTransactionList.Item(k, 3).ToString()
Dim qntyValue As String = String.Empty
If qnty.Length > 3 Then
'If Quantity length is greater then 20, then take substring of quantity 0 to 3.
qnty = qnty.Substring(0, 3)
Else
While qnty.Length <= 3
'Adding " " in Quantity string until length 20.
qntyValue += " "
qnty += " "
End While
End If
qntyValue += qnty.Trim()
displayString += qntyValue
displayString += ESC + "|1lF" + " "
End If
Next k
displayString += ESC + "|1lF"
displayString += ESC + "|cA" + "Thank You for shopping" + ESC + "|1lF"
displayString += ESC + "|cA" + _currSess.Configuration.StoreName + ESC + "|1lF"
displayString += ESC + "|cA" + "We hope you'll come back soon!" + ESC + "|1lF" + ESC + "|1lF" + ESC + "|fP"
_currSess.Register.SetActivePrinterNumber(0)
Dim objRp As Object = _currSess.Register.ReceiptPrinter
objRp.PrintNormal(2, displayString))
objRp.Release()
MsgBox("Gift Receipt printed Successfully.")
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
********* End code *****
******** OutPut Something like this *********
Store Name
Store Address
Gift Receipt
Transaction #: 105
Date: 11/10/2009 Time: 6:10:10
Cashier: 2 Register: 5
Item Description Quantity
567577 xyz 2
687687 abc 4
- - - - -
- - - - -
Any suggestions are welcomed
Thanks
Eliza
Last edited by admin; 01-29-2010 at 10:22 AM.
-
helo Eliza
thank you for ur time the post, it is really gd, but i have some problem in ur code,
currSess.Register.SetActivePrinterNumber(0)
what is currSess and where have define it?
becuz of that i could not use your code, pls help meh you can thank you.
-
Before printing the receipt we need to make a string with using escape sequences, that escape sequences recognized by the printer. displayString += item + vbTab.ToString()
Dim desc As String = dgTransactionList.Item(k, 2).ToString()
Dim descValue As String = String.Empty
displayString += ESC + "|1lF"
displayString += ESC + "|cA" + "Thank You for shopping" + ESC + "|1lF"
displayString += ESC + "|cA" + _currSess.Configuration.StoreName + ESC + "|1lF"
displayString += ESC + "|cA" + "We hope you'll come back soon!" + ESC + "|1lF" + ESC + "|1lF" + ESC + "|fP"
-
Sponsored Ads

Reply With Quote





