From: John on
Here is an bas module:

'begin mod
Public chararray(43)

Function evalbar(bchar As String, Xpos As Long, Ypos As Long, Afdruk As
Object, barwidth As Integer)
Dim linetop As Integer 'top of the line
Dim linebottom As Integer 'bottom of the line
Dim leftside As Integer 'left side of barcode
Dim narbarwidth As Integer 'length of the narrow bars
Dim binarray As Integer 'retrievs the binary code for the current
letter
Dim loop1, loop2, loop3 As Integer
Dim newbchar As String 'hold the modified string

linetop = Ypos
linebottom = Ypos + 500
leftside = Xpos '50
narbarwidth = barwidth '28

'frmbarcode.Picture1.Cls 'clears the picture box
newbchar = "*" + StrConv(bchar, vbUpperCase) + "*" 'add start and stop
char changes string to uppercase
For loop1 = 1 To Len(newbchar) 'loops through each char of the string
binarray = evalchar(Mid(newbchar, loop1, 1))
For loop2 = 1 To Len(chararray(binarray)) 'loops through the
binary array
For loop3 = 1 To (CInt(Mid(chararray(binarray), loop2, 1)) + 1)
* narbarwidth 'checks the width 0 for narrow and 1 for wide
If loop2 Mod 2 Then 'odd char of the string are black, even
are white
'frmbarcode.Picture1.Line (leftside, linetop)-(leftside,
linebottom), vbBlack
Afdruk.Line (leftside, linetop)-(leftside, linebottom),
vbBlack
Else
'frmbarcode.Picture1.Line (leftside, linetop)-(leftside,
linebottom), vbWhite
Afdruk.Line (leftside, linetop)-(leftside, linebottom),
vbWhite
End If
leftside = leftside + 1
Next loop3
Next loop2
For loop2 = 1 To narbarwidth 'adds a white space between char
'frmbarcode.Picture1.Line (leftside, linetop)-(leftside,
linebottom), vbWhite
Afdruk.Line (leftside, linetop)-(leftside, linebottom), vbWhite
leftside = leftside + 1
Next loop2
Next loop1
'Printer.EndDoc
End Function
Function evalchar(echar As String) As Integer
Select Case echar
Case "0"
evalchar = 0
Exit Function
Case "1"
evalchar = 1
Exit Function
Case "2"
evalchar = 2
Exit Function
Case "3"
evalchar = 3
Exit Function
Case "4"
evalchar = 4
Exit Function
Case "5"
evalchar = 5
Exit Function
Case "6"
evalchar = 6
Exit Function
Case "7"
evalchar = 7
Exit Function
Case "8"
evalchar = 8
Exit Function
Case "9"
evalchar = 9
Exit Function
Case "A"
evalchar = 10
Exit Function
Case "B"
evalchar = 11
Exit Function
Case "C"
evalchar = 12
Exit Function
Case "D"
evalchar = 13
Exit Function
Case "E"
evalchar = 14
Exit Function
Case "F"
evalchar = 15
Exit Function
Case "G"
evalchar = 16
Exit Function
Case "H"
evalchar = 17
Exit Function
Case "I"
evalchar = 18
Exit Function
Case "J"
evalchar = 19
Exit Function
Case "K"
evalchar = 20
Exit Function
Case "L"
evalchar = 21
Exit Function
Case "M"
evalchar = 22
Exit Function
Case "N"
evalchar = 23
Exit Function
Case "O"
evalchar = 24
Exit Function
Case "P"
evalchar = 25
Exit Function
Case "Q"
evalchar = 26
Exit Function
Case "R"
evalchar = 27
Exit Function
Case "S"
evalchar = 28
Exit Function
Case "T"
evalchar = 29
Exit Function
Case "U"
evalchar = 30
Exit Function
Case "V"
evalchar = 31
Exit Function
Case "W"
evalchar = 32
Exit Function
Case "X"
evalchar = 33
Exit Function
Case "Y"
evalchar = 34
Exit Function
Case "Z"
evalchar = 35
Exit Function
Case "-"
evalchar = 36
Exit Function
Case "."
evalchar = 37
Exit Function
Case " "
evalchar = 38
Exit Function
Case "$"
evalchar = 39
Exit Function
Case "/"
evalchar = 40
Exit Function
Case "+"
evalchar = 41
Exit Function
Case "%"
evalchar = 42
Exit Function
Case "*"
evalchar = 43
Exit Function
End Select

End Function
Sub setupBarcode()

chararray(0) = "000110100"
chararray(1) = "100100001"
chararray(2) = "001100001"
chararray(3) = "101100000"
chararray(4) = "000110001"
chararray(5) = "100110000"
chararray(6) = "001110000"
chararray(7) = "000100101"
chararray(8) = "100100100"
chararray(9) = "001100100"
chararray(10) = "100001001"
chararray(11) = "001001001"
chararray(12) = "101001000"
chararray(13) = "000011001"
chararray(14) = "100011000"
chararray(15) = "001011000"
chararray(16) = "000001101"
chararray(17) = "100001100"
chararray(18) = "001001100"
chararray(19) = "000011100"
chararray(20) = "100000011"
chararray(21) = "001000011"
chararray(22) = "101000010"
chararray(23) = "000010011"
chararray(24) = "100010010"
chararray(25) = "001010010"
chararray(26) = "000000111"
chararray(27) = "100000110"
chararray(28) = "001000110"
chararray(29) = "000010110"
chararray(30) = "110000001"
chararray(31) = "011000001"
chararray(32) = "111000000"
chararray(33) = "010010001"
chararray(34) = "110010000"
chararray(35) = "011010000"
chararray(36) = "010000101"
chararray(37) = "110000100"
chararray(38) = "011000100"
chararray(39) = "010101000"
chararray(40) = "010100010"
chararray(41) = "010001010"
chararray(42) = "000101010"
chararray(43) = "010010100"


End Sub
'End Module

You first call the setupbarcode sub .
When you want to print you use :
call evalbar("1234567", 100, 800, Printer, 18)
where 100 is X-axis, 800 is y-axis and 18 is the barwidth (Is good for me)

You can also call the printer escape codes to print barcode's.
That I haven't done yet but I think, you have to share you printer and
write your escapecode string to the printer like you write to a text file.

PrintSTR = Chr$(27) & "&E2 12564" & Chr$(13) 'chr$(27) = ESC

Open "//JohnPC//Zebra" For Output As #1
Print #1, PrintSTR;

Close #1

The above is an example !!!!
Hope this helps

greets John

"mjimeno" <miguelangeljimeno(a)hotmail.com> schreef in bericht
news:e0b5ddd77b5cf5ca65bea004510907fd(a)localhost.talkaboutprogramming.com...
> Here is my problem: I want to print to a barcode printer (Zebra 2844) in
> this way: I want to use true type fonts like "Arial Bold", so I used the
> printer method from VB. Perfect. Now I want to print barcodes too, but it
> have been not easy trying with barcode fonts and other methods, so I
> decided to print barcodes using raw data via API programming. Here is the
> exact problem: If I use raw data I can't use windows fonts (according to
> Zebra is possible, but not to me) and if I use printer method I can't
> print perfectly barcodes like with raw data. The question is: Can I send
> raw data using printer method? any other suggestion, please?
> Thanks, Miguel.
>


From: mjimeno on
About your suggestions and questions: the printer is a zebra ctp 2844 with
a resolution of 203 dpi/8 dots per mm, so I guess is good. The problem is
with the barcodes fonts, which don't print small size barcodes. I tried
painting lines like John (I guess it's him) told me, it was the closest
solution using the printer method. But the printer painted thin lines
(like 30 twips I guess) but with very thin lines (12 twips) it started
painting lines with different wides (when they should be the same). So the
barcode scanner can't read them. I know the printer can print very well
small barcodes (1 inch wide with 8 characters) because I tested it with
the software Create a Label 3.0, and myself using raw data (EPL language),
both were read. The question is: can I use both the printer method (for
text with arial font) and the raw data (EPL) to print the barcode at the
same time?

From: mjimeno on
BTW, thanks everybody for your help, codes and suggestions.
M

From: J French on
On Fri, 27 May 2005 09:47:04 -0400, "mjimeno"
<miguelangeljimeno(a)hotmail.com> wrote:

>BTW, thanks everybody for your help, codes and suggestions.
>M
>

Set your scalemode to vbPixels

Twips makes VB do maths - and that is not reliable

There is something called the ESC mode in Windows, for inserting
direct instructions to the printer within a Printer Spooler feed
- I've never got that working
From: Gaga on

"mjimeno" <miguelangeljimeno(a)hotmail.com> wrote in message
news:58caecd4152901cef1362525c043a9db(a)localhost.talkaboutprogramming.com...

> About your suggestions and questions: the printer is a zebra ctp 2844
> with a resolution of 203 dpi/8 dots per mm, so I guess is good.

Actually, that's a fairly poor resolution by modern printer standards. Even
the very cheapest inkjet printer has a native resolution much greater than
that.

> I tried painting lines like John (I guess it's him) told me, it was the
> closest solution using the printer method. But the printer painted
> thin lines (like 30 twips I guess) but with very thin lines (12 twips)
> it started painting lines with different wides (when they should be
> the same).

That's because of the "mismatch" between the desired output size and
position and the "drawn" output size and position, which I briefly mentioned
in my previous response. The operating system has to effectively convert the
"desired values" to "the nearest whole pixel value" when drawing your lines,
and the greater the native printer resolution the better the match will be.
In your case the resolution isn't very good, and so with very thin lines
there will be noticeable differences. A lot depends on the way the printer
driver handles this "whole pixel" conversion thing, but in general it will
decide on a "whole pixel" value for the "left side" of the line and another
"whole pixel value" for the "right side of the line" and it will then
effectively draw a filled rectangle using those values. In the case of a "12
twip thickness line" (as in your example) the thickness of the line will be
1.69 printer pixels. Given that value, some drivers will draw a line that is
2 printer pixels thick regardless of where it is positioned on the page and
other printer drivers will draw a line whose thickness will be either 1 or 2
pixels wide depending on the position it is printed on the page (the
position itself, of course, will also be calculated to the nearest "whole
pixel" value. There are two ways to overcome such problems. The first is to
use a printer with a very high native resolution (such as most modern
inkjets) and the other is to calculate the thickness and position of all
your lines in such a way that both the position and the thickness equate to
"whole pixel" values under all conditions. That, of course, will limit the
total number of different sizes you can print, but with careful choice and
analysis of sizes you should be able to print quite small bar codes. Check
the actual resolution of your printer as it appears to Windows and then play
about with the "whole pixel value" idea. You can easily get the resolution
using the Printer.TwipsPerPixel property (or by one of many other suitable
methods).

> I know the printer can print very well small barcodes (1 inch wide with 8
> characters) because I tested it with the software Create a Label 3.0, and
> myself using raw data (EPL language), both were read.

Yep. That's undoubtedly because the Create a Label software is almost
certainly using some "intelligent analysis" of the desired output bar code
lines taking into account the actual native resolution of the printer. You
should be able to do the same yourself in code in the way that I have
suggested above.

> The question is: can I use both the printer method (for
> text with arial font) and the raw data (EPL) to print the
> barcode at the same time?

I don't know your printer, but in general you cannot mix "raw printer data"
and Windows drawing methods on the same page. (By "raw printer data" I
assume you mean sending control codes and stuff to perform specific
operations). That kind of thing can be done under certain specific
circumstances with certain specific printers, but in general it is not
something you can do.

I don't know anything at all about bar codes, so I can't really help you any
more at the moment. Perhaps you might like to enlighten me. For example, how
many lines does a typical character in a bar code contain, and what is the
range of different thickness.

Whatever you do, you will get the best results if you write code to
"intelligently" analyse the desired output data in terms of the actual
native resolution of the current output device (printer) and then draw the
lines accordingly. The alternative, of course, would be to get yourself a
printer with a much higher resolution, in which case you case you shouldn't
have any problems and there will be no need to perform such analysis. Even
the very cheap almost "give away" inkjets these days will suit your purpose.
Obviously, if you want you code to work on all printers then you will have
tp go with the "intelligent analysis" solution (which I'm almost certain
programs such as Create A Label will use).

Sorry I can't be of more help to you, but I've never done any bar code
programming and so I don't know anything about them.

Mike



First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: VB3 anyone...?
Next: rsidll32