الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كود طباعة الفلكس من اليمين

بدأه أبو زيد في 12 مايو 2008 · 0 رد · 721 مشاهدة · في لغة Ms Visual Basic 6 وما قبلها من إصدارات
مشاركة: واتساب X فيسبوك تيليجرام
#1

أحبابي وجدت هذا الكود ............ و لنني لم أنجح في تنظيم عرض الأعمدة

و هو لطباعة الفلكس من اليمين

كود:

Private Sub Command1_Click()

'*** This Code requires a Form with the MSFlexGrid and the CommonDialog Controls in it, to add it, Right Click the Tool Box \Components\ Microsoft FlexGrid Control 6.0 and the Microsoft Common Dialog Control 6.0

Dim C, R As Integer, Repl As String

Dim Plt(3), L, p, W, txtWidth, Shemal As Single

Printer.RightToLeft = True

Printer.Orientation = 2

On Error GoTo PrintErr '**** Initial the printer Setting ****

CommonDialog1.Orientation = cdlLandscape

CommonDialog1.CancelError = True: CommonDialog1.ShowPrinter: CommonDialog1.Flags = cdlPDPrintSetup

Printer.Orientation = CommonDialog1.Orientation: Printer.Copies = CommonDialog1.Copies

Printer.RightToLeft = True

Printer.FontBold = True: Me.FontName = "Traditional Arabic": Printer.FontName = Me.FontName

Plt(2) = 0

For I = 0 To MSFlexGrid.Cols - 1

Plt(2) = Plt(2) + MSFlexGrid.ColWidth© '**** The Grid Width ****

Next I

If Printer.ScaleWidth >= Plt(2) Then '**** Left Border position ****

Shemal = (Printer.ScaleWidth - Plt(2)) / 2

Else

Shemal = Printer.ScaleLeft + 500

End If

Plt(0) = Shemal '**** Left Border position ****

mytext = "بسم الله الرحمن الرحيم"

Printer.CurrentY = 150

txtWidth = Me.TextWidth(mytext)

Printer.CurrentX = (Printer.ScaleWidth - txtWidth) / 2 '**** Alligne Title in the Center ****

Printer.Print mytext

p = Shemal + 50

Plt(1) = Printer.CurrentY

Printer.FontSize = 12

Printer.DrawStyle = 0: Printer.DrawWidth = 5 '**** To print a line ****

Printer.Line (Plt(0), Printer.CurrentY)-(Plt(2) + Plt(0) + 50, Printer.CurrentY)

Printer.CurrentY = Printer.CurrentY + 50 '**** Print the heading ****

For C = 0 To MSFlexGrid.Cols - 1

If C = 0 Then

p = p + 50

Printer.CurrentX = p

Printer.Print MSFlexGrid.TextMatrix(0, C);

p = p - 50

p = p + MSFlexGrid.ColWidth©

C = C + 1

End If

If C = MSFlexGrid.Cols - 41 Then

p = p + 1200

Printer.CurrentX = p

Printer.Print MSFlexGrid.TextMatrix(0, C);

p = p - 1200

p = p + MSFlexGrid.ColWidth©

C = C + 1

End If

Printer.CurrentX = p

Printer.Print MSFlexGrid.TextMatrix(0, C);

p = p + MSFlexGrid.ColWidth©

Next C

Printer.Print

Printer.DrawStyle = 0: Printer.DrawWidth = 5 '**** To print a line ****

Printer.Line (Plt(0), Printer.CurrentY)-(Plt(2) + Plt(0) + 50, Printer.CurrentY)

Me.FontBold = False: Printer.FontBold = False

Me.FontSize = 10: Printer.FontSize = Me.FontSize

For R = 1 To MSFlexGrid.Rows - 1

If R = MSFlexGrid.Rows - 1 Then

Printer.CurrentY = Printer.CurrentY + 200

Else

Printer.CurrentY = Printer.CurrentY + 15

End If

p = Shemal + 50

For C = 0 To MSFlexGrid.Cols - 1 '**** To Allign the numbers to Right ****

If MSFlexGrid.TextMatrix(0, C) = "Price" Or MSFlexGrid.TextMatrix(0, C) Like "Qty*" Or MSFlexGrid.TextMatrix(0, C) = "Value" Then '**** The Column Head in Red For Numbers****

W = MSFlexGrid.ColWidth© - TextWidth(Me.MSFlexGrid.TextMatrix(R, C)) - 80

Printer.CurrentX = p + W '**** Add the (Column Width - Text Width) ****

Else

Printer.CurrentX = p

End If

If R = MSFlexGrid.Rows - 1 Then

p = p + 1000

Printer.CurrentX = p

Printer.FontSize = 12

Printer.Print MSFlexGrid.TextMatrix(R, C);

p = p - 1000

p = p + MSFlexGrid.ColWidth©

Else

Printer.Print MSFlexGrid.TextMatrix(R, C);

p = p + MSFlexGrid.ColWidth©

End If

Next C

Printer.Print

Printer.DrawStyle = 0: Printer.DrawWidth = 5

If R = MSFlexGrid.Rows - 1 Then

Printer.CurrentY = Printer.CurrentY + 200

End If

Printer.Line (Plt(0), Printer.CurrentY)-(Plt(2) + Plt(0) + 50, Printer.CurrentY)

GoTo NewP

Resu:

If Printer.CurrentY > Printer.ScaleHeight - 1000 Then '**** If End Of Page ****

Printer.NewPage

'

Printer.Print

Printer.CurrentY = 400

Plt(1) = Printer.CurrentY + 100

Plt(0) = Shemal

Printer.DrawStyle = 0

Printer.DrawWidth = 5 '**** To print a line ****

Printer.Line (Plt(0), Plt(1))-(Plt(0) + Plt(2) + 50, Plt(1))

Printer.CurrentY = Printer.CurrentY + 50 '**** Print the heading ****

Printer.FontBold = True: Me.FontSize = 12: Printer.FontSize = Me.FontSize

p = Shemal + 50

For C = 0 To MSFlexGrid.Cols - 1

If C = 0 Then '"?"

p = p + 50

Printer.CurrentX = p

Printer.Print MSFlexGrid.TextMatrix(0, C);

p = p - 50

p = p + MSFlexGrid.ColWidth©

C = C + 1

End If

If C = MSFlexGrid.Cols - 41 Then '"?????"

p = p + 1200

Printer.CurrentX = p

Printer.Print MSFlexGrid.TextMatrix(0, C);

p = p - 1200

p = p + MSFlexGrid.ColWidth©

C = C + 1

End If

Printer.CurrentX = p

Printer.Print MSFlexGrid.TextMatrix(0, C);

p = p + MSFlexGrid.ColWidth©

Next C

Printer.Print

Printer.DrawStyle = 0: Printer.DrawWidth = 5 '**** To print a line ****

Printer.Line (Plt(0), Printer.CurrentY)-(Plt(0) + Plt(2) + 50, Printer.CurrentY)

Printer.FontBold = False: Printer.FontSize = 10

End If

Next R

Printer.EndDoc

Exit Sub

NewP:

L = Shemal + Plt(2) - 400

Plt(3) = Printer.CurrentY

Printer.DrawStyle = 0

Printer.DrawWidth = 5

Printer.Line (Plt(2) + Plt(0) + 50, Plt(1))-(Plt(2) + Plt(0) + 50, Plt(3)) '**** Right Line ****

Printer.Line (Plt(0), Plt(1))-(Plt(0), Plt(3)) '**** Left Line ****

Printer.DrawStyle = 0: Printer.DrawWidth = 5

For C = 1 To MSFlexGrid.Cols - 1

If C = 9 Or C = 17 Or C = 25 Or C = 34 Then

Printer.DrawStyle = 0: Printer.DrawWidth = 15

Else

Printer.DrawStyle = 0: Printer.DrawWidth = 5

End If

Printer.Line (L, Plt(1))-(L, Plt(3)) '**** Vertical Lines ****

L = L - MSFlexGrid.ColWidth©

Next C

GoTo Resu

PrintErr:

If Err.Number = 32755 Then '**** The Printing is canceled ****

MsgBox "Printing is Terminated", vbInformation, "Stop Printing..."

Else

MsgBox Err.Description, vbInformation, "Error in Printing..."

Exit Sub

End If

End Sub

و أريد كذلك طريقة تنسيق النص في المشاركة

مواضيع مشابهة