IMPRESSAO COM O PRINT !!!
Alguém tem idéia de como alinhar a esquerda as colunas de dados obtidas através de uma consulta "SQL" usando print para imprimir direto na impressora ?
segue o código:
Open Porta & ":" For Output As #1
rsSQLPVDetails.MoveFirst
Do Until rsSQLPVDetails.EOF
Print #1, LMargem & rsSQLPVDetails("Peca") & Space(SpacosCodigo) & rsSQLPVDetails("Descricao") & Space(SpacosDesc) & Format(rsSQLPVDetails("Quantidade"), "00000") & Space(SpacosQtde) & rsSQLPVDetails("Un") & Space(SpacosUn) & Format(rsSQLPVDetails("Unitario"), "#,##0.00;(#,##0.00)") & Space(SpacosUnitario) & Format(rsSQLPVDetails("TotalPeca"), "#,##0.00;(#,##0.00)")
rsSQLPVDetails.MoveNext
Loop
Print #1,
Print #1,
Close #1
segue o código:
Open Porta & ":" For Output As #1
rsSQLPVDetails.MoveFirst
Do Until rsSQLPVDetails.EOF
Print #1, LMargem & rsSQLPVDetails("Peca") & Space(SpacosCodigo) & rsSQLPVDetails("Descricao") & Space(SpacosDesc) & Format(rsSQLPVDetails("Quantidade"), "00000") & Space(SpacosQtde) & rsSQLPVDetails("Un") & Space(SpacosUn) & Format(rsSQLPVDetails("Unitario"), "#,##0.00;(#,##0.00)") & Space(SpacosUnitario) & Format(rsSQLPVDetails("TotalPeca"), "#,##0.00;(#,##0.00)")
rsSQLPVDetails.MoveNext
Loop
Print #1,
Print #1,
Close #1
Por exemplo:
Print #1, LMargem & ColocaEspacos(rsSQLPVDetails("Peca"),10) & " " & ColocaEspacos(rsSQLPVDetails("Descricao"),50) & " " & Format(rsSQLPVDetails("Quantidade"), "00000") & " " & ColocaEspacos(rsSQLPVDetails("Un"),5) & " " & ColocaEspacos(Format(rsSQLPVDetails("Unitario"), "#,##0.00;(#,##0.00)"),15) & " " & ColocaEspacos(Format(rsSQLPVDetails("TotalPeca"), "#,##0.00;(#,##0.00)") ,15)
private Function ColocaEspacos(cString as string, TamanhoFinal as Long) as String
Dim i as Long
Dim TamanhoInicial as Long
cString=trim(cString)
TamanhoInicial=len(cString)
if TamanhoInicialTamanhoFinal
for i=TamanhoInicial to TamanhoFinal
cString=" " & cString
next i
endif
ColocaEspacos=cString
end function
Abraços,
Print #1, LMargem & ColocaEspacos(rsSQLPVDetails("Peca"),10) & " " & ColocaEspacos(rsSQLPVDetails("Descricao"),50) & " " & Format(rsSQLPVDetails("Quantidade"), "00000") & " " & ColocaEspacos(rsSQLPVDetails("Un"),5) & " " & ColocaEspacos(Format(rsSQLPVDetails("Unitario"), "#,##0.00;(#,##0.00)"),15) & " " & ColocaEspacos(Format(rsSQLPVDetails("TotalPeca"), "#,##0.00;(#,##0.00)") ,15)
private Function ColocaEspacos(cString as string, TamanhoFinal as Long) as String
Dim i as Long
Dim TamanhoInicial as Long
cString=trim(cString)
TamanhoInicial=len(cString)
if TamanhoInicialTamanhoFinal
for i=TamanhoInicial to TamanhoFinal
cString=" " & cString
next i
endif
ColocaEspacos=cString
end function
Abraços,
Tópico encerrado , respostas não são mais permitidas