borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2009 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (manage print job)Next Topic (Choose Printer) New Topic New Poll Post Reply
AndreaVB Forum : Printing : Printing items in a listbox
Poster Message
Greatest1
Level: Guest


icon Printing items in a listbox

Hi,
I have a project to do for my VB class I am taking.  This application involves a sequential access data file called lc6.dat (on my hard drive).  There is a list box, that when I choose an item, I can then use the print item on the menu I created.  My question is, how do I print the one item that I seleced from the list?  I have to code the Print menu's Record by Item option so that it prints a report showing only the lc6.dat record whose item number matches the item number selected in the list box.  At the end of the report, it is to display the total number of records printed, as well as "End of report" message.

This is all I have for now, (the printer code was the previous exercise I had to do):

Option Explicit

Private Sub Form_Load()
    frmComputer.Top = (Screen.Height - frmComputer.Height) / 2
    frmComputer.Left = (Screen.Width - frmComputer.Width) / 2
    lstItem.AddItem "ABC11"
    lstItem.AddItem "CVA33"
    lstItem.AddItem "BDX22"
    lstItem.ListIndex = 0
End Sub


Private Sub mnuFlieExit_Click()
    Unload frmComputer
    
End Sub


Private Sub mnuPrintARecords_Click()
    
  
    Dim x As Integer
    Dim s As String

    x = FreeFile
    On Error GoTo HandleError
    Open "d:vb classtut06lc6.dat" For Input As x
    Do While Not EOF(x)
        Line Input #x, s
        Printer.Print s
    Loop
    Printer.EndDoc
    Close #x
    Exit Sub
HandleError:
    MsgBox "Error :" & Err.Description, vbCritical, "Printing File..."


End Sub


Thank you,

Laurie

22-02-2003 at 08:38 PM
| Quote Reply
AndreaVB Forum : Printing : Printing items in a listbox
Previous Topic (manage print job)Next Topic (Choose Printer) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2009 Andrea Tincaniborder