English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i have created vb form which have List1 & i want to print
only List1 so please give me the code. please

2007-10-01 06:30:12 · 3 answers · asked by ash 1 in Computers & Internet Programming & Design

3 answers

Load your list box with items then from a command button event index through each item in the list and assign the text to a string variable. Append a LfCr to the end of the string and use the Printer object to print the string

After printing each line then end the document with the EndDoc function and this will finalize the Printer object and send it to the printer.

This will work for short lists which will fit on a single page. If you have longer lists then you will have to count the printed lines and use the newDoc function to start a new page and continue printing.

Private Sub Form_Load()
Dim str As String
Dim x As Integer

For x = 0 To 10
str = x
Me.List1.AddItem (str)
Next

End Sub
Private Sub Command1_Click()
Dim x As Integer
Dim max As Integer
Dim str As String
Dim prn As Printer

With Me.List1
max = .ListCount - 1
For x = 0 To max
.ListIndex = x
str = .Text & vbCrLf
Printer.Print (str)
Next x
End With

Printer.EndDoc

End Sub

2007-10-01 08:55:12 · answer #1 · answered by MarkG 7 · 0 1

print list1

2007-10-01 08:26:40 · answer #2 · answered by the man the myth the answerer 5 · 0 2

Don't bother with Visual basic 6.0 it is old and out-dated, download the newest edition here: http://msdn.microsoft.com/vstudio/express/

2007-10-01 08:26:54 · answer #3 · answered by Anonymous · 0 1

fedest.com, questions and answers