Greatest1 Level: Guest

|
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
|