In Option Explicit
Dim Pr As New EasyPrint 'istanzio la classe
Dim Dx As Single 'margine DX
Dim Sx As Single 'margine SX
Dim AltCar As Single ' altezza del carattere
Private Type EsempioLista
Materiale() As String
Costo() As Long
End Type
Dim ListaMateriale As EsempioLista
Nel Form:
Private Sub Stampa_Click()
Dim Temp As Integer
Dim x As Integer
Dim TotPrg1 As Long
Dim TotPrg2 As Long
Dim Passo As Single 'distanza tra le righe
On Error Resume Next
Call FormatFontDettaglio
Passo = 0
TotPrg1 = 0
TotPrg2 = 0
With Pr
Dim Pr As New EasyPrint 'utilizzato per istanzianziare la classe
Dim Dx As Single 'margine DX
Dim Sx As Single 'margine SX
Dim AltCar As Single ' altezza del carattere
Private Type EsempioLista
Materiale() As String
Costo() As Long
End Type
Dim ListaMateriale As EsempioLista
'.PrintPicture Sx, 10, Logo
.PrintPicture 8, 10, Logo
'personalizzo le caratteristiche del font
.FontItalic = False
.FontName = "Verdana"
.FontBold = False
.FontItalic = True
.FontSize = 8
.FontName = "Verdana"
.ForeColor = &HFF0000
.PrintLeft 12, 50, Label1(60).Caption
.PrintLeft 45, 60, Text1 .Text 'Text1 è in Multiline = True
.PrintLeft 45, 60, Text2.Text
...
...
...
End With
Pr.EndDoc
End Sub
Mentre nella Classe insieme ad altre funzioni:
Private Function GetLineFromString(strText As String, NumLinea As Long) As String
Dim Inizio As Long
Dim strTemp As String
Dim strLine As String
strTemp = strText
For Inizio = 0 To NumLinea
strLine = ""
'estrae la linea di testo carattere per carattere ' è in Left e Right che mi da errore
Do Until (Left (strTemp, 1) = vbCr) Or (Len(strTemp) = 0)
strLine = strLine & Left (strTemp, 1)
strTemp = Right (strTemp, Len(strTemp) - 1)
Loop
If Inizio = NumLinea Then
GetLineFromString = Trim(strLine)
Else
If Len(strTemp) <> 0 Then
'elimina il carattere accapo (carriage return)
If Left(strTemp, 1) = vbCr Then strTemp = Right(strTemp, Len(strTemp) - 1)
End If
If Len(strTemp) <> 0 Then
'elimina eventualmente il carattere line feed (vbLf)
If Left(strTemp, 1) = vbLf Then strTemp = Right(strTemp, Len(strTemp) - 1)
End If
strTemp = Trim(strTemp)
End If
Next Inizio
End Function
Ciao Claudio