Sub Process_Globals
Dim usb1 As UsbSerial
Dim astreams1 As AsyncStreams
End Sub
#Region EXAMPLE POSPRINTER
Sub aprostampante
If usb1.UsbPresent(1) = usb1.USB_NONE Then
Log("Msgbox - no device")
Msgbox("No USB device or accessory detected!", "Error")
Log("Msgbox - returned")
Return
End If
Log("Checking permission 1")
If (usb1.HasPermission(1)) Then
Log(usb1.DeviceInfo(1))
usb1.SetCustomDevice(usb1.DRIVER_SILABS, 0x493, 0x8760)
Dim dev As Int
dev = usb1.Open(19200, 1)
If dev <> usb1.USB_NONE Then
Log("Connected successfully! 1")
astreams1.Initialize(usb1.GetInputStream, usb1.GetOutputStream, "astreams1")
usb1.SetParameters(19200, usb1.DATABITS_8,usb1.STOPBITS_1, usb1.PARITY_NONE)
stampafattura
Else
Log("Error opening USB port 1")
End If
Else
usb1.RequestPermission(1)
End If
End Sub
Sub stampafattura
Dim SendMsg As String
SendMsg = "HOUSE FOOD & ROOMS"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "LOCATION: TAKE AWAY"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "TEL: 0302-774477, 0302-773399, 024-4145444"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "CASHIER: TAKE AWAY PM"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = DateTime.Date(DateTime.Now) & " " & DateTime.Time(DateTime.Now)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "ORDER NO:" & ordine_consegna
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "*******************************"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "RECEIPT NO: XXXXXXXXX"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
Dim d_qta As String = "QTY"
Dim d_desc As String = "ITEM"
Dim d_price As String = "U/PRICE"
Dim d_total As String = "TOTAL"
Dim myString As String=Chr(27) & "D" & Chr(4) & Chr(17) & Chr(27) & Chr(0) & d_qta & Chr(9) & d_desc & Chr(9) & d_price & Chr(9) & d_total
astreams1.Write(myString.GetBytes("UTF8"))
astreams1.Write(Array As Byte(13, 10))
For i = 0 To 3
Dim qta As String = i
Dim ii As Int = Rnd(0, 1000)
Dim descrizione As String = "Descrizione " & i & ii
descrizione = descrizione.SubString2(0,13)
Dim price As String = "30.14"
astreams1.Write(Array As Byte(13, 10))
Dim mydetails As String=Chr(27) & "D" & Chr(4) & Chr(19) & Chr(26) & Chr(0) & qta & Chr(9) & descrizione & Chr(9) & price & Chr(9) & price
astreams1.Write(mydetails.GetBytes("UTF8"))
Next
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "*******************************"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
Dim contototale As Double = 121.60
Dim totalenhis As Double = contototale * 0.0244
Dim totalevat As Double = contototale * 0.1275
Dim subtotale As Double = contototale - totalenhis - totalevat
SendMsg = "SUB - TOTAL: " & NumberFormat2(subtotale, 0, 2, 2, True)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "NHIS: " & NumberFormat2(totalenhis, 0, 2, 2, True)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "VAT: " & NumberFormat2(totalevat, 0, 2, 2, True)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "*******************************"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "AMOUNT DUE: " & NumberFormat2(contototale, 0, 2, 2, True)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "*******************************"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "PAID: " & NumberFormat2(contototale, 0, 2, 2, True)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "*******************************"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "VAT NO: 221V44449"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "PHONE ORDERS: 11:00AM - 10:00PM"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "COME AGAIN"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = "*******************************"
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
SendMsg = Chr(13) & Chr(10)
astreams1.Write(SendMsg.GetBytes("UTF8"))
End Sub
Sub Astreams1_NewData (Buffer() As Byte)
Log("NewData 1")
Log(BytesToString(Buffer, 0, Buffer.Length, "UTF8"))
End Sub
Sub AStreams1_Error
Log("Error: " & LastException)
astreams1.Close
End Sub
Sub Astreams1_Terminated
Log("Terminated")
astreams1.Close
End Sub
#End Region EXAMPLE POSPRINTER