ชุมชนคนรักภาษาเบสิค - Visual Basic Community

 ลืมรหัสผ่าน
 ลงทะเบียน
ค้นหา
ดู: 3603|ตอบกลับ: 1

[VB6] แจกโค้ดการพิมพ์ใบแจ้งหนี้ออกกระดาษครึ่ง A4 ร่วมกับ FarPoint Spread เพื่อทำการแก้ไขข้อมูลได้

[คัดลอกลิงก์]

311

กระทู้

502

โพสต์

6072

เครดิต

ผู้ดูแลระบบ

ทองก้อน ทับทิมกรอบ

Rank: 9Rank: 9Rank: 9

เครดิต
6072




จากโค้ดตัวอย่างครั้งก่อน แจกโค้ดการพิมพ์ใบแจ้งหนี้ห้องพัก/อพาร์ทเมนท์ ออกกระดาษครึ่ง A4 เป็นการนำข้อมูลจาก Excel แบบแถวเดียวมาพิมพ์ แต่อาศัยการเลื่อนตำแหน่งหลัก ซึ่งปกติคนทั่วๆไปมักไม่ค่อยได้ใช้งานกันสักเท่าไหร่ (แต่แอดมินจำเป็นและบ่อยครั้งมาก 5555+) ... คราวนี้มาดูการป้อนข้อมูลในตารางคล้ายๆกับ Excel โดยกระทำผ่านทาง FarPoint Spread เพื่ออำนวยความสะดวกให้กับผู้ใช้ (End Users) ได้ดียิ่งขึ้น ซึ่งเราจะต้องมีการล็อค หรือเช็คค่าต่างๆในแต่ละเซลล์ให้ถูกต้องเสียก่อน จึงจะส่งออกไปพิมพ์รายงานแบบ Hard Copy ด้วย ActiveReports 2.0 ... บทความและโค้ดชุดนี้ จะเน้นไปที่การควบคุม FarPoint Spread เพราะส่วนการออกรายงาน และการใช้ Initial File (INI) ต่างก็เหมือนเดิมครับ แอดมินไม่พูดมาก เจ็บคอ 5555+ ...


หากท่านบังเอิญผ่านมาเจอเว็บไซต์แห่งนี้ ต้องดูรายละเอียดตามลิ้งค์ด้านล่างนี้ก่อนด้วยครับ
[VB6] แจกฟรีโค้ดการพิมพ์ใบแจ้งค่าใช้จ่าย แบบกระดาษครึ่ง A4 ด้วย FarPoint Spread และ ActiveReports 2.0
[VB6] การป้อนข้อมูลรายละเอียดการขายสินค้าเข้าสู่ตาราง FarPoint Spread


ดาวน์โหลด FarPoint Spread COM 8 (Update 8.0.21) (สำหรับสมาชิกเท่านั้น)


มาดูโค้ดในส่วนของฟอร์มหลัก ...
  1. ' / --------------------------------------------------------------------------------
  2. ' / Developer : Mr.Surapon Yodsanga (Thongkorn Tubtimkrob)
  3. ' / eMail : thongkorn@hotmail.com
  4. ' / URL: http://www.g2gnet.com (Khon Kaen - Thailand)
  5. ' / Facebook: https://www.facebook.com/g2gnet (For Thailand)
  6. ' / Facebook: https://www.facebook.com/commonindy (Worldwide)
  7. ' / Purpose: Print bill on paper size A5.
  8. ' / Microsoft Visual Basic 6.0 (SP1) + FarPoint Spread 8.0
  9. ' /
  10. ' / This is open source code under @CopyLeft by Thongkorn Tubtimkrob.
  11. ' / You can modify and/or distribute without to inform the developer.
  12. ' / --------------------------------------------------------------------------------
  13. Option Explicit
  14. Dim strCell1 As String
  15. Dim strCell2 As String

  16. Private Sub cmdPrint_Click()
  17.     Dim rptPrint As Object
  18.     '// ActiveReports Setup
  19.     Set rptPrint = New arSlipA5
  20.     Set Me.ARViewerSlip.object = rptPrint
  21.     '// Zoom 90%
  22.     ARViewerSlip.Zoom = 90
  23. End Sub

  24. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  25.     Select Case KeyCode
  26.         Case vbKeyF7:   Call cmdPrint_Click
  27.         Case vbKeyF10:  Unload Me
  28.     End Select
  29. End Sub

  30. Private Sub Form_Load()
  31.     Me.Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
  32.     txtFirstName.Text = "นางสาวฮานามิ"
  33.     txtLastName.Text = "อิชิตันกรีนที"
  34.     txtMonth.Text = "สิงหาคม 2561"
  35.     txtRoomNo.Text = "A111"
  36.     ' ตั้งค่าเริ่มต้นให้กับ Spread
  37.     Call SetupSpread
  38.     Call DemoData
  39.     '// โฟกัสไปยังเซลล์ที่ต้องการ
  40.     fp.SetActiveCell 4, 1
  41. End Sub

  42. ' ==========================================================
  43. ' โปรแกรมย่อยที่กำหนดค่าคุณสมบัติ (Properties) ต่างๆ ให้กับ Spread
  44. Sub SetupSpread()
  45. ' ==========================================================
  46.     ' แสดงแถบแสงหรือไม่แสดง
  47.     fp.OperationMode = OperationModeNormal
  48.     'fp.OperationMode = OperationModeSingle    ' แถบ Selection
  49.     'fp.OperationMode = OperationModeRead     ' ไม่มีแถบ
  50.     'fp.OperationMode = OperationModeRow
  51.    
  52.     ' สามารถจัดเรียง หรือ Sort Order บนหัวคอลัมภ์ได้
  53.     fp.UserColAction = UserColActionSort
  54.    
  55.     ' ปรับหน่วยวัด
  56.     'fp.UnitType = UnitTypeNormal
  57.     'fp.UnitType = UnitTypeTwips
  58.     'fp.UnitType = UnitTypeVGABase ' ค่าตั้งต้น (Default) วัดหน่วย Pixel แบบใน .NET ใช้
  59.     ' การปรับความสูงของแถวทุกๆแถว (ค่า -1 หมายถึงทุกแถวครับ)
  60.     fp.RowHeight(-1) = 20 '390
  61.     'fp.Appearance = AppearanceFlat ' = Appearance3D
  62.     fp.AppearanceStyle = AppearanceStyleEnhanced
  63.    
  64.     ' เวลากด F2 เพื่อแก้ไขข้อมูลในแต่ละเซลล ์ให้เลือกข้อมูลทั้งหมด หรือสามารถเริ่มคีย์ค่าใหม่ได้ทันที
  65.     fp.EditModeReplace = True
  66.     'fp.GridSolid = True
  67.    
  68.     ' กำหนดให้หลักสุงสุดจำนวน 5 หลัก
  69.     fp.MaxCols = 5
  70.     fp.MaxRows = 9
  71.     ' กรณีของการ UnBound Control ต้องมาปรับรูปแบบก่อนครับ
  72.     With fp
  73.         ' ปรับความกว้างของแต่ละหลักโดยอัตโนมัติ ... แล้วค่อยปรับทีละหลักอีกก็ได้
  74.         '.DAutoSizeCols = DAutoSizeColsBest
  75.         ' หลักแรก คือ หลักที่ 0 ... จะเป็นการแสดงหมายเลขแถว เพื่ออ้างอิงในลักษณะ Excel เช่น
  76.         ' A10 ก็คือหลัก A แถวที่ 10 ... ในกรณีที่เรามองแบบ Excel
  77.         '.ColWidth(1) = 0
  78.         .SetText 0, 0, "รายการชำระเงิน"
  79.         .SetText 1, 0, "PK" '/ Reserve
  80.         .SetText 2, 0, "หน่วยเริ่มต้น"
  81.         .SetText 3, 0, "หน่วยสุดท้าย"
  82.         .SetText 4, 0, "ราคาต่อหน่วย"
  83.         .SetText 5, 0, "รวมจำนวนเงิน"
  84.         ' Set Width
  85.         .ColWidth(0) = 22
  86.         .ColWidth(1) = 0
  87.         .ColWidth(2) = 17
  88.         .ColWidth(3) = 17
  89.         .ColWidth(4) = 17
  90.         .ColWidth(5) = 17
  91.         ' กำหนดคุณสมบัติต่างๆของแต่ละหลักแบบ Run Time
  92.         .Col = 0
  93.         .TypeVAlign = TypeVAlignCenter
  94.         .TypeHAlign = TypeHAlignLeft
  95.         '//
  96.         .Col = 1
  97.         .Lock = True
  98.         .ColWidth(1) = 0
  99.         .UserResizeCol = UserResizeOff
  100.         .UserResizeRow = UserResizeOff
  101.         '
  102.         .Col = 2
  103.         .TypeTextWordWrap = True
  104.         .TypeVAlign = TypeVAlignCenter
  105.         .TypeHAlign = TypeHAlignRight
  106.         ' กำหนดการป้อนค่าตัวเลขจำนวนเงินเท่านั้น
  107.         .CellType = CellTypeNumber
  108.         ' ตามหลังจุศนิยม
  109.         .TypeNumberDecPlaces = 2
  110.         .TypeNumberMin = 0
  111.         ' ไม่แสดงสัญลักษณ์ตัวเงิน
  112.         .TypeCurrencyShowSymbol = False
  113.         .Lock = False
  114.         
  115.         .Col = 3
  116.         .TypeHAlign = TypeHAlignRight
  117.         .TypeVAlign = TypeVAlignCenter
  118.         .CellType = CellTypeNumber
  119.         .TypeNumberDecPlaces = 2
  120.         .TypeNumberMin = 0
  121.         .TypeCurrencyShowSymbol = False
  122.         .Lock = False
  123.         
  124.         ' หน่วยละ
  125.         .Col = 4
  126.         .TypeHAlign = TypeHAlignRight
  127.         .TypeVAlign = TypeVAlignCenter
  128.         .CellType = CellTypeNumber
  129.         .TypeNumberDecPlaces = 2
  130.         .TypeCurrencyShowSymbol = False
  131.         .TypeNumberShowSep = True
  132.         .Lock = False
  133.         ' รวมจำนวนเงิน
  134.         .Col = 5
  135.         .TypeHAlign = TypeHAlignRight
  136.         .TypeVAlign = TypeVAlignCenter
  137.         .CellType = CellTypeNumber
  138.         .TypeNumberDecPlaces = 2
  139.         .TypeNumberShowSep = True
  140.         .TypeCurrencyShowSymbol = False
  141.         .Lock = True
  142.     End With
  143.     ' Span Cell
  144.     fp.AddCellSpan 2, 9, 5, 9
  145.     fp.SetCellBorder 0, 1, -1, -1, 15, &H808080, CellBorderStyleSolid
  146.    
  147. End Sub

  148. ' /--------------------------------------------------------------------------------------------------------
  149. ' / ข้อมูลทดสอบ
  150. Sub DemoData()
  151. ' /--------------------------------------------------------------------------------------------------------
  152.     ' ใส่ข้อมูลทดสอบ
  153.     With fp
  154.             .Row = 1
  155.             .Col = 0: .Text = "ค่าห้องพัก"
  156.             .Col = 1: .Text = 1
  157.             .Col = 2: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  158.             .Col = 3: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  159.             .Col = 4: .Text = "2,800"
  160.             .Col = 5: .Formula = "D1": .BackColor = &HC0FFFF
  161.             .Row = 2
  162.             .Col = 0: .Text = "ค่าน้ำประปา"
  163.             .Col = 1: .Text = 2
  164.             .Col = 2: .Text = "286.00"
  165.             .Col = 3: .Text = "300.00"
  166.             .Col = 4: .Text = "20.00"
  167.             .Col = 5: .Formula = "(C2-B2) * D2": .BackColor = &HFFFFF0
  168.             .Row = 3
  169.             .Col = 0: .Text = "ค่าไฟฟ้า"
  170.             .Col = 1: .Text = 3
  171.             .Col = 2: .Text = "312.00"
  172.             .Col = 3: .Text = "333.00"
  173.             .Col = 4: .Text = "8.00"
  174.             .Col = 5: .Formula = "(C3-B3) * D3": .BackColor = &HC0FFFF
  175.             .Row = 4
  176.             .Col = 0: .Text = "ค่าอินเทอร์เน็ต"
  177.             .Col = 1: .Text = 4
  178.             .Col = 2: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  179.             .Col = 3: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  180.             .Col = 4: .Text = "100.00"
  181.             .Col = 5: .Formula = "D4": .BackColor = &HFFFFF0
  182.             .Row = 5
  183.             .Col = 0: .Text = "ค่าเคเบิ้ลทีวี"
  184.             .Col = 1: .Text = 5
  185.             .Col = 2: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  186.             .Col = 3: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  187.             .Col = 4: .Text = "0.00"
  188.             .Col = 5: .Formula = "D5": .BackColor = &HC0FFFF
  189.             '
  190.             .Row = 6
  191.             .Col = 0: .Text = "ค่าเก็บขยะ"
  192.             .Col = 1: .Text = 6
  193.             .Col = 2: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  194.             .Col = 3: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  195.             .Col = 4: .Text = "0.00"
  196.             .Col = 5: .Formula = "D6": .BackColor = &HFFFFF0
  197.             '
  198.             .Row = 7
  199.             .Col = 0: .Text = "ค่าปรับล่าช้า"
  200.             .Col = 1: .Text = 7
  201.             .Col = 2: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  202.             .Col = 3: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  203.             .Col = 4: .Text = "0.00"
  204.             .Col = 5: .Formula = "D7": .BackColor = &HC0FFFF
  205.             '
  206.             .Row = 8
  207.             .Col = 0: .Text = "อื่นๆ"
  208.             .Col = 1: .Text = 8
  209.             .Col = 2: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  210.             .Col = 3: .Text = "0.00":   .Lock = True:   .BackColor = &HE0E0E0
  211.             .Col = 4: .Text = "-0.00"
  212.             .Col = 5: .Formula = "D8": .BackColor = &HFFFFF0
  213.             
  214.             ' COLUMN E
  215.             .Row = 9
  216.             .Col = 0: .Text = "รวมจำนวนเงินทั้งสิ้น"
  217.             .Col = 1: .Text = 9
  218.             .Col = 2: .Formula = "SUM(E1:E8)"
  219.             .BackColor = &HFFEFEF
  220.             .Lock = True
  221.             .FontBold = True
  222.             .ForeColor = vbBlue
  223.             .RowHeight(9) = 24
  224.             .TypeNumberDecPlaces = 2
  225.             .TypeNumberShowSep = True
  226.             .TypeHAlign = TypeHAlignRight
  227.             .TypeVAlign = TypeVAlignCenter
  228.     End With
  229.    
  230. End Sub

  231. Private Sub Form_Resize()
  232.     On Error Resume Next
  233.     If Me.Height < 11475 Then
  234.         Me.Height = 11475
  235.         Exit Sub
  236.     End If
  237.     '
  238.     If Me.Width < 11550 Then '9950 Then
  239.         Me.Width = 11550
  240.         Exit Sub
  241.     End If
  242.     '//
  243.     cmdExit.Left = Me.ScaleWidth - cmdExit.Width - 75
  244.     cmdPrint.Left = cmdExit.Left - cmdExit.Width - 60
  245.     fraFP.Move 15, 870
  246.     fraFP.Width = Me.ScaleWidth - 30
  247.     fraFP.Height = fp.Top - fraPrint.Top
  248.     fp.Width = fraFP.Width - 75
  249.     '//
  250.     fraPrint.Width = Me.ScaleWidth - 15
  251.     fraPrint.Height = Me.ScaleHeight - fraFP.Height - fraFP.Top
  252.     ARViewerSlip.Move 15, 120, fraPrint.Width - 60, fraPrint.Height - 180
  253. End Sub

  254. Private Sub Form_Unload(Cancel As Integer)
  255.     '// ลบไฟล์ขยะ (Temporary) ก่อนปิดโปรแกรม
  256.     If Dir$(App.Path & "\*.tmp") <> "" Then Kill App.Path & "\*.tmp"
  257.     Set frmFPG = Nothing
  258.     End
  259. End Sub

  260. ' / --------------------------------------------------------------------------------
  261. '// ก่อนทำการแก้ไข
  262. Private Sub fp_BeforeEditMode(ByVal Col As Long, ByVal Row As Long, ByVal UserAction As FPUSpreadADO.BeforeEditModeActionConstants, CursorPos As Variant, Cancel As Variant)
  263.     ' / ค่าที่สำคัญคือ Col, Row
  264.     ' / รับค่าหลัก, แถว
  265.     fp.Col = Col: fp.Row = Row
  266.     '// เก็บค่าเดิมของหลัก 2 และหลัก 3 เอาไว้เปรียบเทียบมากกว่า/น้อยกว่า
  267.     Select Case Col
  268.         Case 2
  269.             strCell1 = CDbl(fp.Value)
  270.             '// เพิ่มหลักไปรับค่าเดิมในหลัก 3
  271.             fp.Col = Col + 1
  272.             strCell2 = CDbl(fp.Value)
  273.         Case 3
  274.             '// ถอยหลักกลับไปรับค่าเดิมในหลัก 2
  275.             fp.Col = Col - 1
  276.             strCell1 = CDbl(fp.Value)
  277.             fp.Col = Col
  278.             strCell2 = CDbl(fp.Value)
  279.     End Select
  280. End Sub

  281. ' / --------------------------------------------------------------------------------
  282. '// เมื่อแก้ไขข้อมูลในเซลล์แล้วกด Enter ต้องทำการทดสอบค่าเริ่มต้นและค่าสิ้นสุด
  283. Private Sub fp_EditMode(ByVal Col As Long, ByVal Row As Long, ByVal Mode As Integer, ByVal ChangeMade As Boolean)
  284.     fp.Col = Col: fp.Row = Row
  285.     ' ดักจับค่าว่างก่อน หากไม่มีก็ออกจากโปรแกรมย่อยไป
  286.     If IsNull(fp.Value) Or Trim(fp.Value) = "" Then Exit Sub
  287.     ' Mode 0 คือ Edit Mode
  288.     Select Case Mode
  289.         Case 0:
  290.             Select Case Col
  291.                     '// หลัก 2 จะมากกว่าหลัก 3 ไม่ได้ หากใช่ให้แจ้งเตือนพร้อมกับคืนค่าเดิม
  292.                 Case 2:
  293.                     If CDbl(fp.Value) > CDbl(strCell2) Then
  294.                         MsgBox "อย่ามากกว่าหน่วยสุดท้ายซิ เดี๋ยวโดนตบจูบซ่ะหรอก", vbOKOnly + vbInformation, "รายงานความผิดพลาด"
  295.                         fp.Value = CDbl(strCell1)
  296.                     End If
  297.                
  298.                 Case 3:
  299.                     '// หลัก 3 จะน้อยกว่าหลัก 2 ไม่ได้ หากใช่ให้แจ้งเตือนพร้อมกับคืนค่าเดิม
  300.                     If CDbl(fp.Value) < CDbl(strCell1) Then
  301.                         MsgBox "อย่าน้อยว่าหน่วยเริ่มต้นซิ เดี๋ยวโดนตบจูบซ่ะหรอก", vbOKOnly + vbInformation, "รายงานความผิดพลาด"
  302.                         fp.Value = CDbl(strCell2)
  303.                     End If
  304.             End Select
  305.     End Select
  306. End Sub

  307. Private Sub cmdExit_Click()
  308.     Unload Me
  309. End Sub

  310. Private Sub mnuFileExit_Click()
  311.     Unload Me
  312. End Sub

  313. Private Sub mnuFileSetup_Click()
  314.     frmSetup.Show vbModal
  315. End Sub
คัดลอกไปที่คลิปบอร์ด

โค้ดในส่วนของการพิมพ์รายงานด้วย ActiveReports 2.0
  1. ' / --------------------------------------------------------------------------------
  2. ' / Developer : Mr.Surapon Yodsanga (Thongkorn Tubtimkrob)
  3. ' / eMail : thongkorn@hotmail.com
  4. ' / URL: http://www.g2gnet.com (Khon Kaen - Thailand)
  5. ' / Facebook: https://www.facebook.com/g2gnet (For Thailand)
  6. ' / Facebook: https://www.facebook.com/commonindy (Worldwide)
  7. ' / Purpose: Print bill on paper size A5.
  8. ' / Microsoft Visual Basic 6.0 (SP1) + FarPoint Spread 8.0
  9. ' /
  10. ' / This is open source code under @CopyLeft by Thongkorn Tubtimkrob.
  11. ' / You can modify and/or distribute without to inform the developer.
  12. ' / --------------------------------------------------------------------------------
  13. Option Explicit
  14. Dim ItemNo As Integer

  15. Dim GrandTotal As Double

  16. ' / --------------------------------------------------------------------------------
  17. ' / ส่วนการอ่านข้อมูลเข้ามาพิมพ์ ด้วยการนับจำนวนแถวใน FarPoint Spread
  18. Private Sub ActiveReport_FetchData(EOF As Boolean)
  19.     ItemNo = ItemNo + 1
  20.     ' ตรวจสอบจำนวนการพิมพ์ทั้งหมด อ้างถึง frmFPG.fp.DataRowCnt - 1
  21.     If ItemNo > frmFPG.fp.DataRowCnt - 1 Then
  22.         EOF = True
  23.         Exit Sub
  24.     Else
  25.         EOF = False
  26.     End If

  27. End Sub

  28. ' / --------------------------------------------------------------------------------
  29. ' / ส่วนเริ่มต้นการพิมพ์ทุกครั้ง
  30. Private Sub ActiveReport_Initialize()
  31.     PageSettings.Orientation = ddOPortrait
  32.     '// ตั้งค่ากระดาษเอง
  33.     PageSettings.PaperSize = 256
  34.     '// หน่วยวัดเป็น Twip (1440 Twip = 1 Inch = 2.54 Cm.)
  35.     PageSettings.LeftMargin = 500
  36.     PageSettings.RightMargin = 60
  37.     PageSettings.BottomMargin = 100
  38.     PageSettings.TopMargin = 600
  39.     ' ขนาดครึ่ง A4 และ ทำการแปลงหน่วยวัดเป็นเซนติเมตร เพื่อให้ง่ายในการวัดระยะ (1440 Twip = 1 Inch = 2.54 Cm.)
  40.     PageSettings.PaperHeight = (14.5 * 1440 / 2.54)
  41.     PageSettings.PaperWidth = (21 * 1440 / 2.54)
  42.     '
  43.     txtCname.Text = ""
  44.     txtRoomNo.Text = ""
  45.     txtDate.Text = ""
  46.     txtDateMonth.Text = ""
  47.     txtItem.Text = ""
  48.     txtDesc.Text = ""
  49.     txtQTY.Text = ""
  50.     txtUnitPrice.Text = ""
  51.     txtAmount.Text = ""
  52.     txtGrandTotal.Text = 0
  53.     '
  54.     lblRemark1.Caption = ""
  55.     lblRemark2.Caption = ""
  56.     '// อ่านค่า INI File
  57.     Dim strFileINI As String
  58.     strFileINI = App.Path & "\Config.ini"
  59.     '// เช็คว่ามีไฟล์ Config.ini อยู่หรือไม่???
  60.     '// หากไม่มีก็ตั้งค่าเริ่มต้นให้ก่อน
  61.     If Dir(strFileINI) = "" Then
  62.         WriteIniValue strFileINI, "Config", "Owner", "ทองก้อน ฮาเร็ม อพาร์ทเมนท์ 2017"
  63.         WriteIniValue strFileINI, "Config", "Address", "123/456 ถ.กลางเมือง ต.เมืองเก่า อ.เมือง จ.ขอนแก่น โทร.043-XXX-XXX"
  64.         WriteIniValue strFileINI, "Config", "Remark1", "1. กรุณาชำระเงินภายในวันที่ 32 ของทุกเดือน"
  65.         WriteIniValue strFileINI, "Config", "Remark2", "2. การเงินมีปัญหา ใส่ชุดนักศึกษามาหาป๋าทองก้อนได้ตลอด 24 ชั่วโมง"
  66.     End If
  67.     '// อ่านค่า Config ต่างๆเข้ามา
  68.     txtOwner.Text = ReadIniValue(strFileINI, "Config", "Owner")
  69.     txtAddress.Text = ReadIniValue(strFileINI, "Config", "Address")
  70.     lblRemark1.Caption = ReadIniValue(strFileINI, "Config", "Remark1")
  71.     lblRemark2.Caption = ReadIniValue(strFileINI, "Config", "Remark2")
  72. End Sub

  73. ' / --------------------------------------------------------------------------------
  74. ' / ส่วนของการพิมพ์รายละเอียดแต่ละแถว
  75. Private Sub Detail_Format()
  76.     ' ตัวแปร ItemNo กลายเป็นแบบ Static
  77.     txtItem.Text = ItemNo & "."
  78.     ' Description หลัก 0
  79.     frmFPG.fp.Col = 0: frmFPG.fp.Row = ItemNo
  80.     txtDesc.Text = frmFPG.fp.Text
  81.     ' จำนวนหน่วย  หลัก 2 และ 3
  82.     Dim MeterStart As Double: Dim MeterEnd As Double: Dim Meter As Double
  83.     frmFPG.fp.Col = 2
  84.     MeterStart = frmFPG.fp.Text
  85.     frmFPG.fp.Col = 3
  86.     MeterEnd = frmFPG.fp.Text
  87.     Meter = MeterEnd - MeterStart
  88.     ' ค่าน้ำประปา
  89.     If ItemNo = 2 Or ItemNo = 3 Then
  90.         txtDesc.Text = txtDesc.Text & " (" & MeterEnd & " - " & MeterStart & " = " & Meter & " หน่วย)"
  91.     End If
  92.    
  93.     frmFPG.fp.Col = 4
  94.     If frmFPG.fp.Value <> 0 And (MeterStart = 0) And (MeterEnd = 0) Then
  95.         txtQTY.Text = "1.00"
  96.     Else
  97.         txtQTY.Text = Format(Meter, "#,##0.00")
  98.     End If
  99.     ' ราคาต่อหน่วย
  100.     frmFPG.fp.Col = 4
  101.     txtUnitPrice.Text = Format(frmFPG.fp.Text, "#,##0.00")
  102.     ' รวมเงิน
  103.     frmFPG.fp.Col = 5
  104.     txtAmount.Text = Format(frmFPG.fp.Text, "#,##0.00")
  105.     ' หาจำนวนเงินรวม
  106.     GrandTotal = Format(GrandTotal + CDbl(txtAmount.Text), "#,##0.00")
  107.     '
  108.     '// กระโดดไป FetchData เข้ามาใหม่ จนกว่าข้อมูลรายการจำนวนแถวจะนับได้ครบ ถือเป็นการสิ้นสุดการพิมพ์
  109. End Sub

  110. Private Sub GroupFooter1_Format()
  111.     txtGrandTotal.Text = "รวมจำนวนเงินทั้งสิ้น: " & Format(GrandTotal, "#,##0.00") & ""
  112. End Sub

  113. Private Sub GroupHeader1_Format()
  114.     '// อ้างอิงถึงค่าจาก TextBox ในฟอร์ม frmFPG
  115.     txtCname.Text = frmFPG.txtFirstName & " " & frmFPG.txtLastName
  116.     txtRoomNo.Text = frmFPG.txtRoomNo.Text
  117.     txtDate.Text = Format(Now(), "dd/mm/yyyy") & " เวลา: " & Format(Now(), "HH:MM")
  118.     txtDateMonth.Text = frmFPG.txtMonth.Text
  119. End Sub

  120. Private Sub ActiveReport_ReportEnd()
  121.     Set arSlipA5 = Nothing
  122.     Unload Me
  123. End Sub
คัดลอกไปที่คลิปบอร์ด

ดาวน์โหลดโค้ดต้นฉบับ VB6 ได้ที่นี่ ...

ขออภัย! โพสต์นี้มีไฟล์แนบหรือรูปภาพที่ไม่ได้รับอนุญาตให้คุณเข้าถึง

คุณจำเป็นต้อง ลงชื่อเข้าใช้ เพื่อดาวน์โหลดหรือดูไฟล์แนบนี้ คุณยังไม่มีบัญชีใช่ไหม? ลงทะเบียน

x
สิ่งที่ดีกว่าการให้ คือการให้แบบไม่มีที่สิ้นสุด

1

กระทู้

11

โพสต์

37

เครดิต

Newbie

Rank: 1

เครดิต
37
โพสต์ 2018-8-30 16:09:59 | ดูโพสต์ทั้งหมด

ขอบคุณครับท่านอาจารย์

1

กระทู้

11

โพสต์

81

เครดิต

Member

Rank: 2

เครดิต
81
โพสต์ 2018-10-21 22:54:30 | ดูโพสต์ทั้งหมด

ขอบคุณมากคะ
ขออภัย! คุณไม่ได้รับสิทธิ์ในการดำเนินการในส่วนนี้ กรุณาเลือกอย่างใดอย่างหนึ่ง ลงชื่อเข้าใช้ | ลงทะเบียน

รายละเอียดเครดิต

ข้อความล้วน|อุปกรณ์พกพา|ประวัติการแบน|G2GNet.com  

GMT+7, 2024-5-6 00:59 , Processed in 0.223000 second(s), 4 queries , File On.

Powered by Discuz! X3.4, Rev.62

Copyright © 2001-2020 Tencent Cloud.

ตอบกระทู้ ขึ้นไปด้านบน ไปที่หน้ารายการกระทู้