Barcode mapping/scanning issues - barcode

This is driving me mad.
I searched here and Google for a solution but found none.
My boss asked me to prepare a simple Excel sheet to reprint labels when data is too old and gone from our WMS. I thought "Very simple! I will just have two cells: one with human font and one below with barcode". I was too quick.
I can key in our product
BZ-BB1/2589 B
But when I scan the barcode I get
BZ'BB1-2589 BB1
The installed barcode font is "Free 3 of 9".
Why the minus and slash signs are converted ? How can I solve this? And it seems that some text is repeated at the end.
Any help is greatly appreciated.
Thanks.

The font "Free 3 of 9" needs also a VBA code
Public Function Code39$(chaine$)
'V 1.0.0
'Paramètres : une chaine
'Retour : * une chaine qui, affichée avec la police CODE39.TTF, donne le code barre
' * une chaine vide si paramètre fourni incorrect
Dim i%
Code39$ = ""
If Len(chaine$) > 0 Then
'Vérifier si caractères valides
For i% = 1 To Len(chaine$)
Select Case Asc(Mid$(chaine$, i%, 1))
Case 32, 36, 37, 43, 45 To 57, 65 To 90
Case Else
i% = 0
Exit For
End Select
Next
If i% > 0 Then
Code39$ = "*" & chaine$ & "*"
End If
End If
End Function
However, the free font C39HrP24DhTt only needs a formula
="*"&A1&"*"

Keyboard layout issue, people with ENG layout keyboard can scan the barcode properly.

Related

How to send color images with ESC/POS?

I have an Epson CW-C6000 that I'm trying to control with ESC commands. I've gotten text to print, so I know I have the IP address, port, etc correct but cannot for the life of me get an image printed.
Here is my code (running from a Ruby on Rails server, with most of the image truncated):
streamSock = TCPSocket.new( "X.X.X.X", 9100 )
str = "~DYR:PRODIMG,B,P,183208,0,89504E470D...4AE426082" + "^XA" + "^FO150,150^IMR:PRODIMG.PNG^FS" + "^XZ"
streamSock.send( str , 0)
streamSock.close
The image is a .png I converted to hexadecimal with this site:
http://tomeko.net/online_tools/file_to_hex.php?lang=en
I'm mostly using page 10 of this PDF for reference:
https://files.support.epson.com/pdf/pos/bulk/esclabel_apg_en_forcw-c6000series_reve.pdf
Does anyone have a hint? Epson support staff was spectacularly unhelpful.
Also I'm sorry if my formatting is bad; I'm new here and will happily edit my post if something is wrong.
Alright I finally got it working. The command for printing a color .PNG is this:
~DYE:[Image Name].PNG,p,p,[Image Size],0,:B64:[Base64 String]:[CRC]
Things that tripped me up:
-You seem to need the .PNG extension on the file name, even though the Epson manual doesn't show that.
-[Image Size] is the number of characters in the Base64 string, even though the Epson manual says it should be the size of the original .PNG image file. If this is wrong the printer will hang and no longer accept input of any kind until restarted.
-There may be other options, but I could only get it working with a CRC of the hex CRC-16/XMODEM type.
Thanks to K J for his/her suggestions and coming along with me!
Perhaps this material can be used as an additional reference.
They seem to have a completely different command/data format than ESC/POS.
ESC/Label Command Reference Guide
Page 12
1.3.4 About Saving the Graphics and Label Formats in the Printer
With ESC/Label command, you can save graphics and label formats in the printer. The printer has a file system. Data saved in the printer is handled as files and is managed in the following way.
The file system does not have a hierarchy.
The printer has a non-volatile saving device, such as Flash ROM, and a volatile saving device, such as RAM, and different drive letters are allocated for each device.
Files are designated as
"<drive letter> colon <:> <file name> dot <.> <extension>".
Page 40-41
2.8 Printing Graphics
...Details have been omitted. Please refer to the actual document...
2.8.1 Registering a Graphic in a Printer and Printing It
...Pick up some from the content. Please refer to the actual document...
Delete the files that remain in the printer (^ID command).
Register the graphic in the printer (~DY command).
When registering a color graphic, you can use the PNG format. When registering a monochrome graphic, you can register the PNG format or the GRF format.
PNG format Monochrome and color graphics
GRF format Monochrome graphics
The reason to execute the step 1.
To ensure capacity of the storage memory necessary for print which application will perform.
2.8.2 Embedding a Graphic in the Field and Printing It
...Details have been omitted. Please refer to the actual document...
In Addition:
Page 104-106
~DY
[Name]
Save File
[Format]
~DY d: o ,f ,x ,t ,w ,data
...A table detailing the parameters is due, but omitted...
[Function]
...Further detailed explanations and figures of functions and parameters are due, but omitted...
Graphic data is handled as follows.
If the data format is binary, you can use any binary data as Parameter data. At this time, the size of Parameter data must be matched to the size specified in Parameter t.
If the data format is a hexadecimal character string, one character from 1. to 3. below is used as Parameter data. At this time, the size of Parameter data written in binary must be matched to the size specified in Parameter t.
0 to 9, A to F, and a to f in ASCII can be used as hexadecimal graphic data.
ASCII comma <,>, the parameter separator character, is used to separate lines. If a comma is input, processing is carried out as if ASCII 0 was input for the remainder of the line.
G to Y and g to z in ASCII can be used as repetition characters. For example, if I9 is input, processing is carried out as if 999 were input. The following table indicates the number of repetitions.
...Characters and repeat specified number of times table omitted...
Looking at the contents of this Technical Reference Guide, it seems that you can register images with tools instead of commands.
CW-C6000/C6500 Series Technical Reference Guide
Page 173-174
And page 288 outlines the Epson Inkjet Label Printer SDK and also describes the existence of sample programs.
#Farmbot26. I have been attempting this same using vb.Net and as you noted Epson support is not helpful. I'm not sure if it's the actual image data that is wrong, CRC, or the ZPL code as nothing helps. Here's 2 examples that have not worked.
`Dim binaryData As Byte() = System.IO.File.ReadAllBytes(txtPNGFile.Text)
zplImageData = Convert.ToBase64String(binaryData)
crc = calcrc(binaryData, binaryData.Length).ToString("X4")
Dim zplToSend As String = "~DYE:" & Path.GetFileName(txtPNGFile.Text).ToUpper & ",P,P," & zplImageData.Length & ",0,:B64:" & zplImageData & ":" & crc & "^XZ"`
`Dim binaryData As Byte() = System.IO.File.ReadAllBytes(txtPNGFile.Text)
crc = calcrc(binaryData, binaryData.Length).ToString("X4") 'Calculate CRC
zplImageData = BitConverter.ToString(binaryData).Replace("-", "")
Dim zplToSend As String = "~DYE:" & Path.GetFileName(txtPNGFile.Text).ToUpper & ",A,P," & zplImageData.Length & ",0,:B64:" & zplImageData & ":" & crc & "^XZ"`
This is the CRC example I have.
`Function calcrc(ByVal data() As Byte, ByVal count As Integer) As Integer
Dim crc As Integer = 0
For Each b As Byte In data
Dim d As Integer = CInt(b)
crc = crc Xor (d << 8)
For j = 0 To 7
If ((crc And &H8000) <> 0) Then
crc = (crc << 1) Xor &H1021
Else
crc = (crc << 1)
End If
Next
Next
Return crc And &HFFFF
End Function`
I have figured out another solution. Save the PNG Image using the Binary data. I found this when reading the Saved Backup file of Image data using the Epson Settings Utility.
~DYE:FILENAME.PNG,B,P,BINARYFILESIZE,0, BINARYIMGDATA
` Try
Dim binaryData As Byte() = System.IO.File.ReadAllBytes(txtPNGFile.Text)
Dim client As System.Net.Sockets.TcpClient = New System.Net.Sockets.TcpClient()
client.Connect(IP_TextBox1.Text.Replace(" ", ""), txtPort.Text)
Dim writer As System.IO.StreamWriter = New System.IO.StreamWriter(client.GetStream(), Encoding.UTF8)
Using mStream As New MemoryStream(binaryData)
Dim zplToSend As String = "~DYE:" & Path.GetFileName(txtPNGFile.Text).ToUpper & ",B,P," & mStream.Length & ",0,"
writer.Write(zplToSend)
writer.Flush()
mStream.WriteTo(client.GetStream())
writer.Flush()
End Using
writer.Close()
client.Close()
MsgBox("Send Complete", MsgBoxStyle.OkOnly, "Complete")
Catch ex As Exception
MsgBox(ex.Message.ToString, MsgBoxStyle.OkOnly, "ERROR")
End Try`
You can also open the image file in an IMAGE object and resize it as needed. I had to do this for the label size of the printer.

Add and replace data ListBoxes (Visual Studio 2013)

I'm very new to Visual Studio. I want to create a currency converter, using Listboxes. But now i'm stuck with this program.
I have multiple cases in my Listbox. This program works as follow:
The user selects a valuta in Listbox "ListboxMunteenheden"
The program show a InputBox. The user enters a number in the InputBox
The selected item will be added in the Listbox "ListBoxWisselkoersen" and
if it is applicable, the value in "ListBoxWisselkoersen" will be replaced.
I don't get the last point working. The selected item won't appear in ListboxWisselkoersen, and I don't get the old data replaced either.
Can anyone help me with this function?
Private Sub ListBoxMunteenheden_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBoxMunteenheden.SelectedIndexChanged
'De Cases worden aangemaakt om de verschillende Munteenheden aan ListBox Wisselkoersen toe te voegen.
Select Case ListBoxMunteenheden.SelectedIndex
Case 0
'De Amerikaanse Dollar wordt toegevoegd aan ListBoxWisselkoersen
Dim AmerikaanseDollar As Decimal
AmerikaanseDollar = InputBox("Geef de wisselkoers >0 en <500 voor de Euro tov Amerikaanse dollars (1 Euro = .... Amerikaanse Dollar): ")
For i = 0 To ListBoxWisselkoersen.Items.Count - 1
' Er wordt gezocht in de tekst van de valuta en vervangen hem met de nieuwe waarde.
If InStr(ListBoxWisselkoersen.Items(i), "Amerikaanse Dollar") > 0 Then
ListBoxWisselkoersen.Items(i) = "1 Euro = " & AmerikaanseDollar.ToString & " Amerikaanse Dollar"
Else
End If
If AmerikaanseDollar <= 0 Or AmerikaanseDollar >= 500 Then
MsgBox("U dient een andere waarde op te geven, tussen de 1 en 499.", MsgBoxStyle.OkOnly)
'Er wordt gecontroleerd of de waarde tussen de 0 en de 500 ligt. Als de MessageBox hieraan voldoet, zal de functie uitgevoerd worden.
End If
Next

Barcode in Excel

wondering if someone can help me out with the following problem.
I have staff stock areas with items regularly. As part of the stocking they are required to also charge whatever they send out. The issue is that when they charge they do the repetitive task of data entry for each item they charge out.
In my ideal setup, they can scan a barcode and the task would be completed in seconds since the barcode would contain all the data that needs to be entered.
To automate this, I was thinking of creating one barcode that can capture all the required inputs along with the tab, and enter keys they are required to input And then when the barcode is scanned from a paper print out the info would be automatically charged.
The data driving the barcode is in Excel so I'd like to create the barcode in Excel. This is where I need help, I've tried to add barcode font but it's not working and I have no experience in VBA if that is required.Any guidance would be much appreciated!
You may use barcode generation component to generate barcodes from VBA (as pictures) and insert these pictures into Excel.
Below is the sample code for ByteScout BarCode SDK (commercial component compatible with VBA) sample. Basically, if you want you may replace it with any other component that is capable of creating pictures when called from VBA.
' IMPORTANT: This demo uses VBA so if you have it disabled please temporary enable
' by going to Tools - Macro - Security.. and changing the security mode to ""Medium""
' to Ask if you want enable macro or not. Then close and reopen this Excel document
' You should have evaluation version of the ByteScout SDK installed to get it working - get it from https://bytescout.com
' If you are getting error message like
' "File or assembly named Bytescout SDK, or one of its dependencies, was not found"
' then please try the following:
'
' - Close Excel
' - (for Office 2003 only) download and install this hotfix from Microsoft:
' http://www.microsoft.com/downloads/details.aspx?FamilyId=1B0BFB35-C252-43CC-8A2A-6A64D6AC4670&displaylang=en
'
' and then try again!
'
' If you have any questions please contact us at http://bytescout.com/support/ or at support#bytescout.com
'==============================================
'References used
'=================
'Bytescout Barcode SDK
'
' IMPORTANT:
' ==============================================================
'1) Add the ActiveX reference in Tools -> References
'2) Loop through the values from the Column A for which barcode has to be generated
'3) Parse the value to Bytescout Barcode Object to generate the barcode using QR Code barcode type.
'4) Save the generated Barcode Image
'5) Insert the Barcode Image in the Column B
'6) Repeat the steps 3 to 5 till the last Value in Column A
'
'==================================================================
Option Explicit
' declare function to get temporary folder (where we could save barcode images temporary)
Declare Function GetTempPath _
Lib "kernel32" Alias "GetTempPathA" _
(ByVal nBufferLength As Long, _
ByVal lpBuffer As String) As Long
' function to return path to temporary folder
Public Function fncGetTempPath() As String
Dim PathLen As Long
Dim WinTempDir As String
Dim BufferLength As Long
BufferLength = 260
WinTempDir = Space(BufferLength)
PathLen = GetTempPath(BufferLength, WinTempDir)
If Not PathLen = 0 Then
fncGetTempPath = Left(WinTempDir, PathLen)
Else
fncGetTempPath = CurDir()
End If
End Function
Sub Barcode_Click()
'Fetch the Worksheet
Dim mySheet As Worksheet
Set mySheet = Worksheets(1) 'Barcode_Data Sheet
'temp path to save the Barcode images
Dim filePath As String
filePath = fncGetTempPath() 'Change the Path But should end with Backslash( \ )
'Prepare the Bytescout Barcode Object
'====================================
Dim myBarcode As New Bytescout_BarCode.Barcode
myBarcode.RegistrationName = "demo" 'Change the name for full version
myBarcode.RegistrationKey = "demo" 'Change the key for full version
'Barcode Settings
myBarcode.Symbology = SymbologyType_QRCode ' QR Code barcode, you may change to other barcode types like Code 39, Code 128 etc
' set barcode image quality resolution
myBarcode.ResolutionX = 300 'Resolution higher than 250 is good for printing
myBarcode.ResolutionY = 300 'Resolution higher than 250 is good for printing
myBarcode.DrawCaption = True 'Showing Barcode Captions in the Barcode Image
myBarcode.DrawCaptionFor2DBarcodes = True ' show captions for 2D barcodes like QR Code
' first clean the B column from old images (if any)
Dim Sh As Shape
With mySheet
For Each Sh In .Shapes
If Not Application.Intersect(Sh.TopLeftCell, .Range("B1:B50")) Is Nothing Then
If Sh.Type = msoPicture Then Sh.Delete
End If
Next Sh
End With
' now generate new barcodes and insert into cells in the column B
' Repeat the steps for each row from 2 to 6
Dim myVal As Integer
For myVal = 2 To 6 'change the code to all rows with values
'Parse the Value from the Column A to Bytescout Barcode Object
myBarcode.Value = mySheet.Cells(myVal, 1).Text
'Fit the barcode into 80X30 mm rectangle
myBarcode.FitInto_3 80, 30, 4 '4 refers to units of measurement as millimeter
'Save the barcode image to a file in temporary folder
myBarcode.SaveImage filePath & "myBarcode" & myVal & ".png"
'Insert the Barcode image to the Column B and resize them to fit the cell.
'==========================================================================
With mySheet.Pictures.Insert(filePath & "myBarcode" & myVal & ".png")
.ShapeRange.LockAspectRatio = True ' lock aspect ratio
.Left = mySheet.Cells(myVal, 2).Left + 1 ' set left
.Top = mySheet.Cells(myVal, 2).Top + 1 ' set right
.PrintObject = True ' allow printing this object
.Placement = xlMove ' set placement mode to move but do not resize with the cell
.ShapeRange.ScaleHeight 1, True ' set height scale to 1 (no scale)
.ShapeRange.ScaleWidth 1, True ' set width scale to 1 (no scale)
End With
Next myVal ' move to next cell in the column
' Release the Barcode Object.
Set myBarcode = Nothing
End Sub
Disclaimer: I'm relatd to ByteScout

How to display latin characters in vbscript MsgBox

I have a vbscript that open message box, but I'm making an spanish version of the program and the latin characters are not displaying well:
MsgBox "No se ha instalado la Consola de Administración pues debe tener instalado Internet Explorer 8 o superior.", vbExclamation, "Atención"
But when I execute the script this is what is displayed:
As you can see, the Latin characters are not well formatted, does someone could advise me how to fix it?
you need to use the chr(#) equivalent
MsgBox "No se ha instalado la Consola de Administraci" + chr(242) + "n pues debe tener instalado Internet Explorer 8 o superior.", vbExclamation, "Atenci" + chr(242) + "n"

Visual basic - Excel cell's border property

I'm newbie in Visual Basic and I'm tring to build a simply application who perform some operation on an Excel file.
I want to edit the cell's border properties of my sheet, I need to edit the weight and the color of the separate border of some specified cells (for example only the bottom border or the top border).
Ifound some interesting resource on the web:
http://www.functionx.com/vbaexcel/cells/Lesson4.htm
Border around each cell in a range
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/93bb7ff7-0aed-4ce1-adca-aabde5fc3c2c
anyway is impossible to me to follow the suggested example.
This is an extract of my code:
Public Class mytest
Dim oExcel As Object 'Oggetto per la gestione del file Excel
Dim oBook As Object 'Oggetto per la gestione del file Excel
Dim page As Integer = 1 'Indice per la gestione dei fogli Excel
....
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'Creazione nuovo workbook in Excel
oExcel = CreateObject("Excel.Application")
oBook = oExcel.Workbooks.Add
'Add data to cells of the first worksheet in the new workbook
'Apertura file in lettura
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("input.csv")
MyReader.TextFieldType = FileIO.FieldType.Delimited
'Imposto il carattere di separazione tra i campi
MyReader.SetDelimiters(";")
'Creo stringa lettura righe
Dim currentRow As String()
'Leggo 1 volta per saltare
currentRow = MyReader.ReadFields()
'Fino alla fine del file
While Not MyReader.EndOfData
'Mostra riga nella label
lblShowElab.Text = page
Try
'Formatto i fogli
oBook.Worksheets(page).Range("A1:B1").Merge()
oBook.Worksheets(page).Range("A2:B2").Merge()
...
oBook.Worksheets(page).Range("B2").Borders(xlEdgeRight).LineStyle = xlContinuous
oBook.Worksheets(page).Range("B2").Borders(xlEdgeRight).Weight = xlThin
'Leggo riga per riga
currentRow = MyReader.ReadFields()
'Inserisco i campi di ogni riga nella cella voluta
oBook.Worksheets(page).Range("F2").Value = currentRow(14)
oBook.Worksheets(page).Range("A5").Value = currentRow(12)
...
'Incremento la pagina
page = page + 1
'Se la pagina e' maggiore di 3 la devo creare
If page > 3 Then
oBook.Worksheets.Add(After:=oBook.Worksheets(oBook.Worksheets.Count))
End If
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
MsgBox("Line " & ex.Message & "is not valid and will be skipped.")
End Try
End While
lblShowElab.Text = "Elaborazione Terminata"
End Using
'Salva il Workbook ed esce da Excel
oBook.SaveAs("output.xlsx")
oExcel.Quit()
End Sub
End Class
The commands
oBook.Worksheets(page).Range("B2").Borders(xlEdgeRight).LineStyle = xlContinuous
oBook.Worksheets(page).Range("B2").Borders(xlEdgeRight).Weight = xlThin
does not work for me becouse Visual Studio do not recognize and mark me the xlEdgeRight, xlContinuous, xlEdgeRight, xlThin variables and pretend that I declare this.
This commas are common on every example I found in Internet, I do not understand why not works for me. Had I missed some libraries or namespace to declare? What I need?
Hope someone can help me,
Regards, thaks a lot.
All the constants like xlEdgeRight, xlContinuous, xlEdgeRight, xlThin etc are just long integers.
You need to lookup their values and use them in your application.
Ideally you'd create a bunch of constants in your application so you can continue to use the named versions so its easier to understand your code.
The following page lists all the excel constants and their values. http://www.smarterdatacollection.com/Blog/?p=374
I assume there not tied to a specific excel version, but if they are you just need to lookup the ones for your version.

Resources