Public Sub preparastampavendite(ByVal cliente As String, ByVal daseta As DataSet, ByVal l1 As String, ByVal l2 As String, ByVal l3 As String)


tblClienti = daseta.Tables("spese")

End Sub

Dim WithEvents pDoc As Printing.PrintDocument
Dim paginestampate As Integer = 1
Dim cosa As String
Dim indr As Integer
Private Sub pDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pDoc.PrintPage

'In totale quante pagine
Dim MaxPagine As Integer = 2

Dim b As String
Dim lineaDritta As String

Dim sp As Integer

Dim myfont As New Font("Verdana", 10, FontStyle.Regular, GraphicsUnit.Pixel)
Dim myfont2 As New Font("Verdana", 7, FontStyle.Regular, GraphicsUnit.Pixel)
Dim ColWidth As Integer = 0


Dim righe As Integer
Dim spazio As Integer

Dim colonne As Integer
Dim indc As Integer

Select Case (cosa)


Case "Minchia"




righe = tblClienti.Rows.Count
MaxPagine = righe \ 38
If (righe Mod 38) > 0 Then
MaxPagine = MaxPagine + 1
End If
spazio = 20
indc = 0
colonne = tblClienti.Columns.Count
While indc < colonne - 1
e.Graphics.DrawString(tblClienti.Columns(indc).Col umnName, myfont, New SolidBrush(Color.Black), 15 + (indc * 133), 100)
indc = indc + 1
End While


While indr < 39 * paginestampate
e.HasMorePages = False

While indc < colonne - 1
Try
b = CStr(tblClienti.Rows(indr).Item(indc))
lineaDritta = "_________________________________________________ __________________________________________________ __________________________________"

If b = "True" Then
b = "|X|"

End If
If b = "False" Then
b = "| |"
End If
Catch
b = ""
lineaDritta = " "
End Try

e.Graphics.DrawString(b, myfont, New SolidBrush(Color.Black), 15 + (indc * 133), 100 + spazio + sp)
' sp = sp + 10

indc = indc + 1
End While
indc = 0
spazio = spazio + 11 + sp
e.Graphics.DrawString(lineaDritta, myfont, New SolidBrush(Color.Black), 15, 100 + spazio)
indr = indr + 1
spazio = spazio + 15


End While
If paginestampate < MaxPagine Then
'Ci sono altre pagine
e.HasMorePages = True
paginestampate += 1
Else
'Fine delle pagine
e.HasMorePages = False
End If

End Select


End Sub

Private Sub Buttonstampa(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim PrintDialog1 As New PrintDialog
pDoc = New Printing.PrintDocument
PrintDialog1.Document = pDoc
PrintDialog1.AllowSomePages = True
If PrintDialog1.ShowDialog() = DialogResult.OK Then
pDoc.Print()
End If
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
cosa = "Minchia"

preparastampavendite(" ", dasetinvitati, " ", " ", " ")
Buttonstampa(sender, e)
paginestampate = 1
indr = 0
End Sub