Visual Basic Foro
Programación => Visual Basic 6 => Mensaje iniciado por: E N T E R en Marzo 27, 2013, 06:52:13 pm
-
Tengo un texto que supera los limites de la descripción de una factura y prepare un método para recortar pero no puedo alinear la cantidad, p.venta y sub-total como el ejemplo de la segunda factura. como ven en la segunda factura el nº 2 esta alineado por pago publicidad.
(http://snag.gy/66hng.jpg)
Quiero que quede así
(http://snag.gy/BUHU8.jpg)
Este es mi codigo.
Private Sub Command1_Click()
Dim sLineas As Integer
Printer.ScaleMode = 6
For a = 1 To 2
Inicio = 1
Final = 25
xTexto = "PAGO DE PUBLICIDAD MES DE NOVIEMBRE Y DICIEMBRE"
TLineas = Int(Len(xTexto) / Final) + 1
For i = 1 To TLineas
xDescripcion = Trim(Mid(xTexto, Inicio, Final))
Inicio = (i * Final) + 1
nLineas = nLineas + 5
Printer.CurrentX = 32: Printer.CurrentY = 72 + nLineas
Printer.Print xDescripcion
Next i
Printer.CurrentX = 15: Printer.CurrentY = 72 + nLineas: Printer.Print "2"
Printer.CurrentX = 100: Printer.CurrentY = 72 + nLineas: Printer.Print "1.000"
Printer.CurrentX = 141: Printer.CurrentY = 72 + nLineas: Printer.Print "2.000"
Next a
Printer.EndDoc
End Sub
-
Creo que en realidad sólo tienes que crear una variable para memorizar el valor que asignas a CurrentY cuando i del bucle vale 1, o sea cuando imprimer la primera linea de texto.
Algo asi:
Private Sub Command1_Click()
Dim sLineas As Integer
Dim Y As Single
Printer.ScaleMode = 6
For a = 1 To 25
Inicio = 1
Final = 25
xTexto = "PAGO DE PUBLICIDAD MES DE NOVIEMBRE Y DICIEMBRE"
TLineas = Int(Len(xTexto) / Final) + 1
For I = 1 To TLineas
xDescripcion = Trim(Mid(xTexto, Inicio, Final))
Inicio = (I * Final) + 1
nLineas = nLineas + 5
Printer.CurrentX = 32: Printer.CurrentY = 72 + nLineas
If I = 1 Then Y = Printer.CurrentY
Printer.Print xDescripcion
Next I
Printer.CurrentX = 1: Printer.CurrentY = Y: Printer.Print "2"
Printer.CurrentX = 100: Printer.CurrentY = Y: Printer.Print "1.000"
Printer.CurrentX = 140: Printer.CurrentY = Y: Printer.Print "2.000"
Next a
Printer.EndDoc
End Sub
-
Gracias amigo, funciona de maravillas.
Saludos...