Hallo. Ich hänge mal wieder fest. Ich habe mir das Tutorial zum drucken mehrere Seiten durchgelesen und verstehe trotzdem nicht wie man definiert welcher Ausschnitt auf der ersten und welcher auf der zweiten gedruckt werden soll... Mein Programm berechnet die Daten einer Verzahnung. Der User kann zu beginn auswählen welche Werte er berechnen lassen möchte. Je nach Auswahl entstehen mehr oder weniger Zeilen die gedruckt werden sollen. Anhand der Auswahl kann ich vor dem Druck schon die benötigten Zeilen ermitteln. Ich weiß also wo ich gerne die nächste Seite beginnen lassen möchte. Das Programm ist ursprünglich in VB6 und ich versuche den Code weitestgehend zu übernehmen.
Das mit dem Index funktioniert nur bedingt und ist eigentlich auch mein Problem. So wieder Code abgebildet ist druckt er nie die ersten Zeilen, das ist klar... So wie ich es mir denke müßte ich vor jedem zu druckenden Wert eine abfrage machen die prüft auf welcher Seite gedruckt wird. Wie geht man da richtig vor?
Spoiler anzeigen
Spoiler gesetzt und Thema verschoben; Das Thema wird automatisch dort erstellt, wo man sich befindet, wenn man auf [* Neues Thema] klickt. ~VaporiZed
Das mit dem Index funktioniert nur bedingt und ist eigentlich auch mein Problem. So wieder Code abgebildet ist druckt er nie die ersten Zeilen, das ist klar... So wie ich es mir denke müßte ich vor jedem zu druckenden Wert eine abfrage machen die prüft auf welcher Seite gedruckt wird. Wie geht man da richtig vor?
Quellcode
- Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
- RZ = 1
- 'Anzahl der Zeilen bestimmen
- Bedarf = 145
- If frmEvo_S1.Check1.CheckState = 1 Then
- Bedarf = Bedarf + 124
- End If
- If frmEvo_S1.Check2.CheckState = 1 Then
- Bedarf = Bedarf + 188
- End If
- If frmEvo_S1.Check3.CheckState = 1 Then
- Bedarf = Bedarf + 93
- End If
- If frmEvo_S1.Check4.CheckState = 1 Then
- Bedarf = Bedarf + 119
- End If
- If frmEvo_S1.Check5.CheckState = 1 Then
- Bedarf = Bedarf + 53
- End If
- If frmEvo_S1.Check6.CheckState = 1 Then
- Bedarf = Bedarf + 53
- End If
- If frmEvo_S1.Check7.CheckState = 1 Then
- Bedarf = Bedarf + 137
- End If
- If frmEvo_S10.Check2.CheckState = 1 Then
- RZ = 2
- End If
- If frmEvo_S10.Check3.CheckState = 1 Then
- RZ = 3
- End If
- If frmEvo_S10.Check4.CheckState = 1 Then
- RZ = 4
- End If
- If frmEvo_S10.Check5.CheckState = 1 Then
- RZ = 5
- End If
- If frmEvo_S1.Check9.CheckState = 1 Then
- Bedarf = Bedarf + 72 + RZ * 13
- End If
- If frmEvo_S1.Check10.CheckState = 1 Then
- Bedarf = Bedarf + 72 + RZ * 13
- End If
- If frmEvo_S13.Check2.CheckState = 1 Then
- RZ = 2
- End If
- If frmEvo_S13.Check3.CheckState = 1 Then
- RZ = 3
- End If
- If frmEvo_S1.Check12.CheckState = 1 Then
- Bedarf = Bedarf + 83 + RZ * 13
- End If
- If frmEvo_S1.Check11.CheckState = 1 Then
- Bedarf = Bedarf + 137
- End If
- If frmEvo_S1.Check13.CheckState = 1 Then
- Bedarf = Bedarf + 137
- End If
- If Bedarf > 1100 Then
- e.HasMorePages = Index < 1 ' True bei index >= 2
- Index += 1 ' nächste Seite
- End If
- 'Lochermarkierung für 1.Seite
- e.Graphics.DrawLine(BlackPen, 0, Mitte, 30, Mitte)
- 'Überschrift *************************************************************************************************************************************************
- If Index = 0 Then
- Ausgabe = Space(84)
- Mid(Ausgabe, 2, Len(txtKunde.Text)) = txtKunde.Text
- Mid(Ausgabe, 36, Len(txtKomNr.Text)) = txtKomNr.Text
- Mid(Ausgabe, 50, Len(Today) + 2) = CStr(Today)
- LAENGE = Len(txtBearbeiter.Text)
- POS = 75 - LAENGE + 1
- Mid(Ausgabe, POS, LAENGE) = txtBearbeiter.Text
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- 'Underline *********
- Ausgabe = Space(1)
- For J = 1 To 74
- Ausgabe = Ausgabe & "*"
- Next J
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- End If
- 'Basis-Parameter *************************************************************************************************************************************************
- If Index = 0 Then
- Ausgabe = Space(50)
- Mid(Ausgabe, 2, 17) = "BASIS-PARAMETER :"
- YPos = YPos + Zeile * 1.5
- e.Graphics.DrawString(String.Format(Ausgabe), New Font(FontDrucker, FontStyle.Bold), Brushes.Black, New Point(XPos, YPos))
- Ausgabe = Space(41)
- Mid(Ausgabe, 2, 17) = "-----------------"
- YPos = YPos + Zeile * 0.6
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = M
- Teil = "ZÄHNEZAHL" & Space(8) & "MODUL"
- Zusammenstellen()
- Wert = FormatNumber(Z, 0)
- Mid(Ausgabe, 12, Len(Wert)) = Wert
- Ausgabe1 = Ausgabe
- Wert = EW
- Teil = "EINGRIFFSWINKEL......."
- Zusammenstellen()
- Ausgabe = (Ausgabe1 & Space(7) & Ausgabe)
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- If MI = 0 Then GoTo Basis1
- Wert = MI
- Teil = "INNEN-ROLLENMASS MI..."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = RI
- Teil = "MESSROLLE RI.........."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- Basis1:
- If MAB = 0 Then GoTo Basis2
- Wert = MAB
- Teil = "AUSSEN-ROLLENMASS MA.."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = RAB
- Teil = "MESSROLLE RA.........."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- Basis2:
- If WXZ = 0 Then GoTo Basis3
- Wert = WXZ
- Teil = "ZAHNWEITE WXZ........."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = XZ
- Teil = "MESSZÄHNEZAHL........."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- Basis3:
- If SX = 0 Then GoTo Basis4
- Wert = SX
- Teil = "BOGENZAHNDICKE SX....."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = DX
- Teil = "DURCHMESSER DX........"
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- Basis4:
- If S0 = 0 Then GoTo Basis5
- Wert = S0
- Teil = "BOGENZAHNDICKE S0....."
- Zusammenstellen()
- Ausgabe = Ausgabe
- Basis5:
- If MI Or MAB Or WXZ Or SX Or S0 Then GoTo Basis6
- Wert = XM
- '
- Teil = "PROFILVERSCHIEBUNG X*M"
- Zusammenstellen()
- Ausgabe = Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Basis6:
- Wert = LG
- Teil = "LG/2.................."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = RG
- Teil = "RG...................."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile * 2
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = D0
- Teil = "TEILKREIS-DURCHM. D0.."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = SXF(6)
- Teil = "BOGENZAHNDICKE S0....."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = SA
- Teil = "SPITZE AUSSEN........."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = SI
- Teil = "SPITZE INNEN.........."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = PV_Renamed
- Teil = "PROFILVERSCHIEBUNG X*M"
- Zusammenstellen()
- Ausgabe = Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- End If
- 'theoretisches Profil*************************************************************************************************************************************************
- If frmEvo_S1.Check1.CheckState = 1 And Index = 0 Then
- Ausgabe = Space(50)
- Mid(Ausgabe, 2, 22) = "THEORETISCHES PROFIL :"
- YPos = YPos + Zeile * 1.5
- e.Graphics.DrawString(String.Format(Ausgabe), New Font(FontDrucker, FontStyle.Bold), Brushes.Black, New Point(XPos, YPos))
- Ausgabe = Space(50)
- Mid(Ausgabe, 2, 22) = "----------------------"
- YPos = YPos + Zeile * 0.6
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = PD(1)
- Teil = "FORMKREIS INNEN......."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = PD(3)
- Teil = "FORMKREIS AUSSEN......"
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- YPos = YPos + Zeile
- For J = 1 To 3
- Wert = PD(J)
- Teil = "KOORDINATEN IM DURCHM."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = YKR(J)
- NR = Trim(Str(J))
- Teil = "X" & NR & "= Y" & NR & "="
- Zusammenstellen()
- Wert = FormatNumber(XKR(J), 6)
- POS = 15 - Len(Wert)
- Mid(Ausgabe, POS, Len(Wert)) = Wert
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Next J
- Ausgabe = (" THEORETISCHE EINSTELLDATEN:")
- YPos = YPos + Zeile * 1.5
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Ausgabe = Space(52)
- Mid(Ausgabe, 2, 3) = "XT="
- Wert = FormatNumber(XT, 6)
- POS = 16 - Len(Wert)
- Mid(Ausgabe, POS, Len(Wert)) = Wert
- Mid(Ausgabe, 20, 3) = "YT="
- Wert = FormatNumber(YT, 6)
- POS = 34 - Len(Wert)
- Mid(Ausgabe, POS, Len(Wert)) = Wert
- Mid(Ausgabe, 38, 3) = "RT="
- Wert = FormatNumber(RT, 6)
- POS = 52 - Len(Wert)
- Mid(Ausgabe, POS, Len(Wert)) = Wert
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- End If
- 'Formfehler bei Kreisbogen *************************************************************************************************************************************************
- If frmEvo_S1.Check2.CheckState = 1 Then
- Ausgabe = Space(50)
- Mid(Ausgabe, 2, 27) = "FORMFEHLER BEI KREISBOGEN :"
- YPos = YPos + Zeile * 1.5
- e.Graphics.DrawString(String.Format(Ausgabe), New Font(FontDrucker, FontStyle.Bold), Brushes.Black, New Point(XPos, YPos))
- Ausgabe = Space(50)
- Mid(Ausgabe, 2, 27) = "---------------------------"
- YPos = YPos + Zeile * 0.6
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = PD(5)
- Teil = "PRÜFDURCHM: INNEN....."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = PD(6)
- Teil = "PRÜFDURCHM. AUSSEN...."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Ausgabe = Space(70)
- Mid(Ausgabe, 2, 7) = "DURCHM."
- Mid(Ausgabe, 22, 7) = "DURCHM."
- Mid(Ausgabe, 39, 7) = "DURCHM."
- Mid(Ausgabe, 56, 7) = "DURCHM."
- Mid(Ausgabe, 16, 1) = "µ"
- Mid(Ausgabe, 33, 1) = "µ"
- Mid(Ausgabe, 50, 1) = "µ"
- Mid(Ausgabe, 67, 1) = "µ"
- Ausgabe = Ausgabe
- YPos = YPos + Zeile * 2
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- YPos = YPos + Zeile * 1.4
- e.Graphics.DrawLine(BlackPen, XPos + 14, YPos, XPos + e.MarginBounds.Right - 80, YPos)
- YPos = YPos - Zeile * 1.2
- YPosEnd = YPos + 9 * Zeile
- e.Graphics.DrawLine(BlackPen, 220, YPos, 220, YPosEnd)
- e.Graphics.DrawLine(BlackPen, 380, YPos, 380, YPosEnd)
- e.Graphics.DrawLine(BlackPen, 540, YPos, 540, YPosEnd)
- YPos = YPos + Zeile * 0.5
- For J = 0 To 5
- Ausgabe = Space(70)
- ' Ausgabe 1.Spalte
- POS = 11 - Len(PRU(J))
- Mid(Ausgabe, POS, Len(PRU(J))) = PRU(J)
- POS = 18 - Len(XF(J))
- Mid(Ausgabe, POS, Len(XF(J))) = XF(J)
- ' Ausgabe 2.Spalte
- POS = 28 - Len(PRU(J + 6))
- Mid(Ausgabe, POS, Len(PRU(J + 6))) = PRU(J + 6)
- POS = 35 - Len(XF(J + 6))
- Mid(Ausgabe, POS, Len(XF(J + 6))) = XF(J + 6)
- ' Ausgabe 3.Spalte
- POS = 45 - Len(PRU(J + 12))
- Mid(Ausgabe, POS, Len(PRU(J + 12))) = PRU(J + 12)
- POS = 52 - Len(XF(J + 12))
- Mid(Ausgabe, POS, Len(XF(J + 12))) = XF(J + 12)
- If J + 18 > 21 Then GoTo FormFehler
- ' Ausgabe 4.Spalte
- POS = 62 - Len(PRU(J + 18))
- Mid(Ausgabe, POS, Len(PRU(J + 18))) = PRU(J + 18)
- POS = 69 - Len(XF(J + 18))
- Mid(Ausgabe, POS, Len(XF(J + 18))) = XF(J + 18)
- FormFehler:
- Ausgabe = Ausgabe
- YPos = YPos + Zeile * 1.2
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Next J
- Ausgabe = Space(35)
- Länge = Len(FF)
- Mid(Ausgabe, 17, Länge + 1) = FF & "µ"
- Teil = "SUMMEN-FEHLER"
- Mid(Ausgabe, 2, Len(Teil)) = Teil
- Ausgabe = Ausgabe
- YPos = YPos + Zeile * 1.5
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- End If
- 'Kantenbruch-Durchmesser *************************************************************************************************************************************************
- If frmEvo_S1.Check3.CheckState = 1 Then
- Ausgabe = Space(50)
- Mid(Ausgabe, 2, 25) = "KANTENBRUCH-DURCHMESSER :"
- YPos = YPos + Zeile * 1.5
- e.Graphics.DrawString(String.Format(Ausgabe), New Font(FontDrucker, FontStyle.Bold), Brushes.Black, New Point(XPos, YPos))
- Ausgabe = Space(50)
- Mid(Ausgabe, 2, 25) = "-------------------------"
- YPos = YPos + Zeile * 0.6
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = LN
- Teil = "LÄNGSNUTENGRUND......."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = BD
- Teil = "BEZUGSDURCHMESSER....."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = KB
- Teil = "KANTENBRUCH-BREITE...."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = KW
- Teil = "KANTENBRUCH-WINKEL...."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = KD
- Teil = "KANTENBRUCH-DURCHM...."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = IK
- Teil = "SPITZE-INNEN KANTENBR."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile * 2
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = LK
- Teil = "LX KANTENBRUCH-DURCHM."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = LL
- Teil = "LX LÄNGSNUTENGRUND...."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = BN
- Teil = "SX LÄNGSNUTENGRUND...."
- Zusammenstellen()
- Ausgabe1 = Ausgabe
- Wert = SK
- Teil = "STOLLENBREITE........."
- Zusammenstellen()
- Ausgabe = Ausgabe1 & Space(7) & Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- Wert = VV
- Teil = "VERTIKAL-VERFAHREN...."
- Zusammenstellen()
- Ausgabe = Ausgabe
- YPos = YPos + Zeile
- e.Graphics.DrawString(String.Format(Ausgabe), FontDrucker, Brushes.Black, New Point(XPos, YPos))
- End If
- und soweiter....
- End Sub
Spoiler gesetzt und Thema verschoben; Das Thema wird automatisch dort erstellt, wo man sich befindet, wenn man auf [* Neues Thema] klickt. ~VaporiZed
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „VaporiZed“ ()