Visual Basic - IMPRIMIR LISTBOX

Life is soft - evento anual de software empresarial
 
Vista:

IMPRIMIR LISTBOX

Publicado por Energy (32 intervenciones) el 21/07/2007 15:49:45
ALGUIEN SABE COMO MANDAR IMPRIMIR EL CONTENIDO DE UN LISTBOX???

GRACIAS

ES KE KIERO HACER UNA CONSULTA E IMPRIMIR EL RESULTADO DEL LISTBOX

GRACIAS
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:IMPRIMIR LISTBOX

Publicado por Natalia Camino (46 intervenciones) el 21/07/2007 19:49:33
Private Sub Command1_Click()
Dim i As Integer
For i = 0 To List1.ListCount - 1
List1.ListIndex = i
Printer.Print List1.Text
Next i
Printer.EndDoc
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:IMPRIMIR LISTBOX

Publicado por emanuel (1 intervención) el 06/03/2020 14:15:50
me re sirbio grasias
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:IMPRIMIR LISTBOX

Publicado por EZE STRATOS (1 intervención) el 30/07/2007 14:32:46
EN EL MODULO...
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

EN EL FORM:
Public Sub gsImprimir(qControl As Control, Optional vLPT, Optional vDirecto)
'--------------------------------------------------------------
'Procedimiento genérico para imprimir (31/Ago/97)
'
'Entrada:
' qControl control a imprimir (TextBox, ListBox)
' vLPT Impresora de salida, sólo para impresión directa
' vDirecto Si se imprime directamente o se usa el controlador
'--------------------------------------------------------------
Const MAXLINEA = 136 'Número de caracteres máximos por línea

Dim nFicSal As Integer
Dim sLpt As String
Dim i As Long
Dim j As Integer
Dim k As Long
Dim sTmp As String
Dim sImpresora As String
Dim bDirecto As Boolean
Dim tPrinter As Printer

Dim L1&, L2&
Const EM_GETLINECOUNT = &HBA
Const EM_LINEINDEX = &HBB
Const EM_LINELENGTH = &HC1

Set tPrinter = Printer

'El port de impresora a usar
If IsMissing(vLPT) Then 'Si no se especifica,
sLpt = "LPT1:" 'usar LPT1:
Else
sLpt = CStr(vLPT)
End If
'Si se va a imprimir directamente en el puerto
'o se va a usar el controlador de Windows
If IsMissing(vDirecto) Then 'Si no se especifica,
bDirecto = False 'usar el controlador de Windows
Else
bDirecto = CBool(vDirecto)
End If

'Quitarle los dos puntos, si lo tiene,
'seguramente no es necesario, pero...
If Right$(sLpt, 1) = ":" Then
sLpt = Left$(sLpt, Len(sLpt) - 1)
End If

If TypeOf qControl Is ListBox Then
'Número de items en el listbox
k = qControl.ListCount
Else
'Número de líneas del TextBox
k = SendMessage(qControl.hWnd, EM_GETLINECOUNT, 0, 0&)
End If
If bDirecto Then
'Imprimir directamente...
j = 0
nFicSal = FreeFile
'Abrir el puerto de impresora para salida...
Open sLpt For Output As nFicSal
Print #nFicSal, Chr$(15); 'Letra pequeña
Else
'Usar controlador de Windows
tPrinter.Print ""
tPrinter.Print ""
End If
'Se imprimirá cada una de las líneas del listbox o del textbox
'-------------------------------------------------------------
'En este último caso no sería necesario,
'ya que se puede imprimir TODO de una vez, usando esto:
'Printer.Print qControl.Text 'usando el controlador
'Print #nFicSal, qControl.Text 'imprimiendo directamente
'-------------------------------------------------------------
For i = 0 To k - 1
DoEvents
If TypeOf qControl Is ListBox Then
If bDirecto Then
Print #nFicSal, Left$(qControl.List(i), MAXLINEA)
Else
tPrinter.Print Left$(qControl.List(i), MAXLINEA)
End If
Else
'Primer carácter de la línea actual
L1 = SendMessage(qControl.hWnd, EM_LINEINDEX, i, 0&) + 1
'Longitud de la línea actual
L2 = SendMessage(qControl.hWnd, EM_LINELENGTH, L1, 0&)
If L2 > MAXLINEA Then L2 = MAXLINEA
If bDirecto Then
Print #nFicSal, Mid$(qControl.Text, L1, L2)
j = j + 1
'cada 60 líneas en una página
If j = 60 Then
Print #nFicSal, Chr$(12);
j = 0
End If
Else
tPrinter.Print Mid$(qControl.Text, L1, L2)
End If
End If
Next
If bDirecto Then
'Restaurar el tamaño de la fuente a normal
Print #nFicSal, Chr$(18);
'Si j vale CERO, ya se imprimió un salto de página
'en caso contrario, echar la hoja fuera
If j Then
Print #nFicSal, Chr$(12);
End If
Close nFicSal
Else
tPrinter.EndDoc
End If
End Sub

SALUDOS!!

EZE
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:IMPRIMIR LISTBOX

Publicado por irwinconcha (1 intervención) el 15/03/2015 17:57:51
Muchas gracias por su aporte, me imprime desordenado este ejemplo que está publicado.
RBD : colegio10
LIBRO MAYOR, RANGO : 01-03-2015 al 15-03-2015
======================================================================================================================================
NUMERO TIP CODIGO TIPO NUMERO FECHA
FECHA COMPROB. COM GLOSA D/H AUXILIAR DOCU BC DOCUMENTO VENCIMIENTO D E B E H A B E R
--------------------------------------------------------------------------------------------------------------------------------------
Saldo de arrastre 0 0
06-03-2015 00000002 I BANCO DEL ESTADO DE CHILE D DEPO 02 000000000123 06-03-2015 1000000 0
07-03-2015 00000003 E AHUMADA CABELLO LTDA. H 077070080-9 CHEGI 02 000000000111 07-03-2015 0 700000
07-03-2015 00000004 E INDUSTRIA DE MUEBLES Y EST H 077671760-6 CHEGI 23 000000009876 08-04-2015 0 273000
07-03-2015 00000003 E AHUMADA CABELLO LTDA. D 077070080-9 FAC 00 000000002224 07-03-2015 700000 0
06-03-2015 00000002 I ARRIENDO H FACEL 17 000000000000 06-03-2015 0 1000000
07-03-2015 00000004 E INDUSTRIA DE MUEBLES Y EST D 077671760-6 FAC 00 000000012345 08-03-2015 273000 0
--------------------------------------------------------------------------------------------------------------------------------------
** T O T A L E S M E S ** 1973000 1973000
** TOTALES ACUMULADOS (mes + arrastre) ** 1973000 1973000
** S A L D O F I N A L ** 0 0
=======================================================================================
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de LUIS FRANCO

RE:IMPRIMIR LISTBOX

Publicado por LUIS FRANCO (93 intervenciones) el 16/03/2015 05:29:22
Hola amigo Buenas Noches

No se que deseas hacer, si me das mas pista por favor te puedo ayudar.

Utilizo para reportes Crystal Report lo has utilizado?. Te recomiendo que lo uses puede serte de gran utilidad. sI TIENES DUDA PORFA ENVIAME UN CORREO A VER EN QUE TE PUEDO AYUDAR.

Sin mas por el momento se despide
LF
[email protected]
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar