Results 1 to 9 of 9

Thread: Printing Barcode as Text File... HELP

  1. #1

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Unhappy

    Dear All....

    I've got a project for production department. Everyday, the production department should print out some barcode ticket for the employee(s) target.

    Currently, we're using clipper s/w language. And Now, I want to change it to VB s/w language.

    Does anybody know how to do it ??? But, please, no crystal report for the solutions. Coz, I know how to do it in crystal or data report... I've got the font for barcode (if I use crystal or data report)...

    I want to print the barcode ticket using text print out, directly print to printer... Got what I mean ???

    Thx a lot guys...
    nd Cheers...

    Wen Lie
    Regards,
    [-w-]

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    I'm not sure if I understand?
    Do you have the barcode fonts?
    If so simply use the Printer object.
    Code:
    Printer.Font.Name = "TheNameOfTheFont"
    Printer.Font.Size = <TheFontSize>
    Printer.Print "Whatever"
    Printer.EndDoc

  3. #3

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Unhappy

    Well... Joacim

    I've tried your way...
    but... too bad... Doesn't work for the barcode font...
    The print out just the same with the word I've typed.
    Nothing different at all.

    Do you have any suggestions.. ???
    or Does any body have any suggestions ???

    I'll be waiting forward to hear...
    coz, I need this badly for my office production target ticketing.

    Cheers,
    Wen Lie
    Regards,
    [-w-]

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    I'm afraid the font isn't a TrueType font then. Or did you made it yourself?

    I believe there's a way to print the whole in the exact way it's on the screen so:

    Printer.Printform

    ^ I believe that's it.

    Have Fun
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    Joacim's method should work. I have used it in several projects. Are you sure you've properly installed the font, and used the correct name?

    Printer.Font.Name = "3 of 9 Barcode"
    Printer.Font.Size = 16
    Printer.Print "*Whatever*"
    Printer.EndDoc

  6. #6

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524

    Unhappy

    Thx...

    I've tried it...
    so far so good...
    But now,
    I'm stuck in arranging their position...
    suppose, in a page,
    I want to print 8 rows of barcode with 2 column for each row.

    How should I do that ???

    Thx in advice,
    nd need soon, very soon....

    HELP...

    Cheers,
    Wen Lie
    Regards,
    [-w-]

  7. #7
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    What a coïncidence!! I just did that today. I wrote a routine to print reject and defect codes in Barcode on A4 format. 16 on a page (2 * 8).
    I will include the code. Of course you have to adjust it, because I retrieved the data to print, from a selection made in a treeview, and a database. I marked this part in the code.

    Code:
    Private Sub PrintRejDefBarcodes()
    Dim cnt As Integer
    Dim nodDept As Node
    Dim sSql As String
    Dim rs As Recordset
    Dim sText As String
    Dim YY As Double
    Dim sSel As String
    Dim prevKind As String
        
        Printer.ScaleMode = vbMillimeters
        ' FORGET ABOUT THIS CODE! IT IS ONLY USED TO CREATE A SQL STATEMENT
        ' THAT WILL RETURN THE DATA I PRINT ON THE BARCODES. REPLACE IT WITH YOUR OWN
        ' CODE TO GET THE DATA YOU NEED
        cnt = 0
        sSel = ""
        ' loop through the nodes to collect the workcenter Rkey's
        For Each nodDept In tvwResource.Nodes
            ' only include if checked
            If nodDept.Image = "Checked" Then
                ' only include the second level (workcenters)
                If GetNodeLevel(nodDept) = 2 Then
                    sSel = sSel & Right(nodDept.Key, Len(nodDept.Key) - 1) & ", "
                End If
            End If
        Next
        sSql = "Select Data0039.Rej_Code, Data0039.Reject_Description, Data0039.Reject_Defect_Flag From Data0039, Data0040"
        sSql = sSql & " Where Data0039.Rkey = Data0040.Reject_Code_Ptr(+) And (Data0040.Dept_Ptr = Null"
        If Len(sSel) > 0 Then
            sSql = sSql & " OR Data0040.Dept_Ptr In (" & Left(sSel, Len(sSel) - 2) & ")"
        End If
        sSql = sSql & ") Order By Data0039.Reject_Defect_Flag, Data0039.Rej_Code"
        Set rs = conPar.OpenRecordset(sSql, dbOpenSnapshot, dbExecDirect)
        '
        ' OK. NOW START PAYING ATTENTION
        '
        If Not rs.EOF Then
            prevKind = Trim(UCase(rs("Reject_Defect_Flag")))
            While Not rs.EOF
                ' a new page when already printed 16 codes or when the
                ' Reject_Defect_Flag changes
                If (cnt Mod 16 = 0) Or prevKind <> Trim(UCase(rs("Reject_Defect_Flag"))) Then
                    ' print the footer if it's not the first page
                    If cnt <> 0 Then
                        ' Print the footer, and pass the number of rows printed so far
                        ' This is used to calculate the Y positions
                        Call PrintFooter(((((cnt + 1) \ 2) - 1) Mod 8) + 1)
                        Printer.NewPage
                    End If
                    ' print a new header
                    If rs("Reject_Defect_Flag") = "R" Then
                        Call PrintHeader("OVERZICHT REJECT CODES")
                    Else
                        Call PrintHeader("OVERZICHT DEFECT CODES")
                    End If
                    If prevKind <> Trim(UCase(rs("Reject_Defect_Flag"))) Then
                        ' start counting from 0 if Reject_Defect_Flag has changed
                        cnt = 0
                        prevKind = Trim(UCase(rs("Reject_Defect_Flag")))
                    End If
                End If
                
                With Printer.Font
                    .Name = "3 of 9 Barcode"
                    .Size = 28
                    .Bold = False
                    .Underline = False
                End With
                YY = 34.5 + (((cnt \ 2) Mod 8) * 28) + 5
                sText = "*" & Trim(UCase(rs("Rej_Code"))) & "*"
                Call PrT(36.5 + ((cnt Mod 2) * 75), YY, sText)
                YY = YY + 4
                Call PrT(36.5 + ((cnt Mod 2) * 75), YY, sText)
                YY = YY + 3.5
                Call PrT(36.5 + ((cnt Mod 2) * 75), YY, sText)
                
                With Printer.Font
                    .Name = "Arial"
                    .Size = 10
                    .Bold = False
                    .Underline = False
                End With
                
                YY = YY + 7.5
                sText = rs("Reject_Description")
                Call PrT(36.5 + ((cnt Mod 2) * 75), YY, sText)
                YY = YY + 4
                sText = "(" & rs("Rej_Code") & ")"
                Call PrT(36.5 + ((cnt Mod 2) * 75), YY, sText)
                
                cnt = cnt + 1
                rs.MoveNext
            Wend
        End If
        Call PrintFooter(((((cnt + 1) \ 2) - 1) Mod 8) + 1)
        Printer.EndDoc
    
    End Sub
    
    
    Private Sub PrintFooter(ByVal NoBarcodes As Integer)
    Dim YY As Double
        YY = 34.5 + (NoBarcodes * 28) + 10
        'vertical lines
        Printer.Line (26, 34)-(26.5, YY + 0.5), vbBlack, BF
        Printer.Line (176, 34)-(176.5, YY + 0.5), vbBlack, BF
        'horizontal line
        Printer.Line (26, YY)-(176, YY + 0.5), vbBlack, BF
    
    End Sub
    
    
    Private Sub PrintHeader(ByVal Header As String)
    Dim sText As String
        With Printer.Font
            .Name = "Arial"
            .Bold = False
            .Underline = False
            .Size = 5
        End With
        sText = Format(Date, "dd-mm-yyyy")
        Call PrT(167, 6, sText)
        With Printer.Font
            .Bold = True
            .Underline = True
            .Size = 10
        End With
        sText = Header
        Call PrT((Printer.ScaleWidth - Printer.TextWidth(sText)) / 2, 11, sText)
        'horizontal lines
        Printer.Line (26, 21)-(176, 21.5), vbBlack, BF
        Printer.Line (26, 34)-(176, 34.5), vbBlack, BF
        'vertical lines
        Printer.Line (26, 21)-(26.5, 34.5), vbBlack, BF
        Printer.Line (176, 21)-(176.5, 34.5), vbBlack, BF
        ' gray box
        Printer.Line (26.5, 21.5)-(176, 34), RGB(200, 200, 200), BF
        Printer.Font.Underline = False
        sText = UCase(txtDescription.Text)
        Call PrT((Printer.ScaleWidth - Printer.TextWidth(sText)) / 2, 22, sText)
        With Printer.Font
            .Bold = False
            .Size = 8
        End With
        sText = "BARCODE TERMINAL ID : " & lblTermId.Caption & "  COMPUTER : " & txtCompName.Text
        Call PrT((Printer.ScaleWidth - Printer.TextWidth(sText)) / 2, 31, sText)
    End Sub
    
    Private Sub PrT(x As Double, y As Double, sText As String)
        Printer.CurrentX = x
        Printer.CurrentY = y
        Printer.Print sText
    End Sub

  8. #8

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524
    Thx...
    I will try your code...

    nd if got any problem,
    i'll contact you....

    Cheers,
    Wen Lie
    Regards,
    [-w-]

  9. #9

    Thread Starter
    Fanatic Member Wen Lie's Avatar
    Join Date
    Jul 1999
    Location
    Singapore
    Posts
    524
    Dear Frans

    I've tried your code...
    but, I'm still confuse about one thing...

    Your code has limited of printing 8 rows per page (16 details per page)...
    how if I want to increase them... supppose, I want to make 16 rows per page (32 details per page)... Where should I change the code...

    2nd question...
    Since my office use special paper to print out barcode ticket, I can't use printer.newpage
    I just want to make several spaces after 16 rows I've printed out.
    How should I do this... ???

    Thx a lot in reply...

    Cheers,
    Wen Lie
    Regards,
    [-w-]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width