CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Jan 2008
    Posts
    19

    printing invoice in DOT MATRIX PRINTER (USB ) in VB6

    I am developing a sample project in Visual basic 6 and MS Access 2003.

    1. I wish to print Invoice in Continuous statonery (Roll Paper ) width of paper 5.5 inches
    I am using printer.print Code using (x,y) co-ordinates

    My problem , after printing one bill printer skips and giving lot of space between two bills. My aim printer must stop printing after completing one bill. ( no gaps required ) and user tear off that bill and continue to print next bill.

    I am printing invoice in DOT MATRIX PRINTER (USB )

    My code is
    Code:
    Dim cy As Long
    Dim cx As Long
    Dim cx1 As Long
    Dim tmpval As Double
    
    Set rs = New ADODB.Recordset
    sql = "select * from del_head where tran=" & Trim(txtcustno.Text) & ""
    rs.Open sql, CN, adOpenStatic, adLockPessimistic
    If rs.RecordCount > 0 Then
    
    cno = rs(2)
    custname = rs(3)
    ctown = rs(8)
    
    Set rs3 = New ADODB.Recordset
    rs3.Open "select sum(amountdue)-sum(amountrec) from receipt_d where cid = " & cno & "", CN, adOpenStatic, adLockPessimistic
    custdue = rs3(0)
    rs3.Close
    
    
    Printer.Font = "Arial"
    Printer.FontBold = True
    Printer.FontSize = 12
    Printer.CurrentX = 3400
    Printer.CurrentY = 50
    Printer.Print " XXXXXXXXXXXXXXXX "
    Printer.Font = "Arial"
    Printer.FontBold = False
    Printer.FontSize = 10
    Printer.CurrentX = 3400
    Printer.CurrentY = 350
    Printer.Print "  XXXXXXXXXXXXXXXXXXXXX  "
    Printer.Font = "Arial"
    Printer.FontBold = False
    Printer.FontSize = 11
    Printer.CurrentX = 2600
    Printer.CurrentY = 650
    Printer.Print "  XXXXXXXXXXXXXXXXXXXX "
    Printer.Font = "Arial"
    Printer.FontBold = False
    Printer.FontSize = 11
    Printer.CurrentX = 3300
    Printer.CurrentY = 950
    Printer.Print "  XXXXXXXXXXXXXXXXXXXX "
    
    Printer.Font = "Arial"
    Printer.FontBold = False
    Printer.FontSize = 9
    Printer.CurrentX = 6400
    Printer.CurrentY = 50
    Printer.Print "  XXXXXXXXXXXXXXXX "
    
    Printer.Font = "Arial"
    Printer.FontBold = False
    Printer.FontSize = 9
    Printer.CurrentX = 6400
    Printer.CurrentY = 200
    Printer.Print "      :   XXXXXXXXXXXXXXXX "
    
    Printer.Font = "Arial"
    Printer.FontBold = False
    Printer.FontSize = 9
    Printer.CurrentX = 6350
    Printer.CurrentY = 550
    Printer.Print "    XXXXXXXXXXXXXXXX"
    
    
    Printer.CurrentX = 1000
    Printer.CurrentY = 1150
    Printer.FontSize = 9
    Printer.Print " Bill No : " & rs(1)
    
    Printer.CurrentX = 3600
    Printer.CurrentY = 1150
    Printer.FontSize = 8
    Printer.Print " INVOICE "
    
    Printer.CurrentX = 6150
    Printer.CurrentY = 1150
    Printer.FontSize = 9
    Printer.Print "  Date : " & rs(4)
    
    Printer.Line (1000, 1400)-(7800, 1400) '-h line
    
    'Printer.Line (20, 10)-(20, 18800) 's1
    'Printer.Line (11520, 10)-(11520, 18800) 's2
    'Printer.Line (10, 18800)-(11500, 18800) 'bl
    
    Printer.Font = "DCI + Tml + Ismail"
    Printer.CurrentX = 100
    Printer.CurrentY = 1550
    Printer.Print "           tpguk;                     fp          tpiy             bjhif"
    
    Printer.Line (1000, 1800)-(7800, 1800) '-h line
    
    
    
    
    cy = 2000
    cx = 6500
    Set rs1 = New ADODB.Recordset
    sql = "select * from del_det where transno=" & Trim(txtcustno.Text) & ""
    rs1.Open sql, CN, adOpenStatic, adLockPessimistic
    Do While Not rs1.EOF
    
    
    Printer.Font = "DCI + Tml + Ismail"
    Printer.CurrentX = 1100
    Printer.CurrentY = cy
    Printer.Print rs1(3)
    
    Printer.Font = "Arial"
    Printer.FontSize = 10
    
    Printer.CurrentX = 3500
    Printer.CurrentY = cy
    Printer.FontSize = 9
    Printer.Print rs1(4)
    
    
    Printer.CurrentX = 4700 - TextWidth(rs1(5))
    Printer.CurrentY = cy
    Printer.Print Format(rs1(5), "00.00")
    
    Printer.CurrentX = cx - TextWidth(rs1(6))
    Printer.CurrentY = cy
    Printer.Print Format(rs1(6), "00.00")
    
    
    'Format$(123,"@@@@@@")
    
    rs1.MoveNext
    cy = cy + 250
    Loop
    Printer.Line (6000, cy)-(7800, cy) '-h line
    
    Printer.Font = "DCI + Tml + Ismail"
    Printer.CurrentX = 4500
    Printer.CurrentY = cy + 100
    Printer.FontSize = 10
    Printer.Print " bkhj;jk; "
    
    Printer.Font = "Arial"
    Printer.CurrentX = cx - TextWidth(rs(7))
    Printer.CurrentY = cy + 100
    Printer.FontSize = 10
    Printer.Print Format(rs(7), "00.00")
    cy = cy + 300
    Printer.Line (6000, cy)-(7800, cy) '-h line
    
    Printer.Font = "DCI + Tml + Ismail"
    Printer.CurrentX = 4500
    Printer.CurrentY = cy + 300
    Printer.FontSize = 10
    Printer.Print " bkhj;j ghf;fp "
    
    Printer.Font = "Arial"
    Printer.CurrentX = cx - TextWidth(custdue)
    Printer.CurrentY = cy + 300
    Printer.FontSize = 10
    Printer.Print Format(custdue, "00.00")
    cy = cy + 600
    Printer.Line (6000, cy)-(7800, cy)   '-h line
    Printer.EndDoc
    End If
    Last edited by DataMiser; December 13th, 2015 at 11:05 AM. Reason: added code tags

Tags for this Thread

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

Featured