VERSION 5.00 Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX" Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX" Begin VB.Form expdate BackColor = &H00C0C0C0& Caption = "โปรแกรมต่ออายุวารสาร" ClientHeight = 8490 ClientLeft = 60 ClientTop = 345 ClientWidth = 11880 Icon = "Expdate.frx":0000 LinkTopic = "Form1" MDIChild = -1 'True ScaleHeight = 8490 ScaleWidth = 11880 WindowState = 2 'Maximized Begin VB.CommandButton Cmdcancel BackColor = &H00C0E0FF& Caption = "ยกเลิก" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 855 Left = 10080 Picture = "Expdate.frx":0442 Style = 1 'Graphical TabIndex = 32 Top = 5760 Visible = 0 'False Width = 1455 End Begin MSComCtl2.MonthView MonthView4 Height = 2370 Left = 4080 TabIndex = 31 Top = 6000 Visible = 0 'False Width = 2490 _ExtentX = 4392 _ExtentY = 4180 _Version = 393216 ForeColor = 0 BackColor = 12632256 Appearance = 1 MonthBackColor = 16777152 StartOfWeek = 20774914 TitleBackColor = 8388736 TitleForeColor = 8454143 TrailingForeColor= 8421504 CurrentDate = 38622 End Begin MSComCtl2.MonthView MonthView3 Height = 2370 Left = 4080 TabIndex = 30 Top = 6000 Visible = 0 'False Width = 2490 _ExtentX = 4392 _ExtentY = 4180 _Version = 393216 ForeColor = -2147483630 BackColor = 8388736 Appearance = 1 MonthBackColor = 16777152 StartOfWeek = 20774914 TitleBackColor = 8388736 TitleForeColor = 8454143 TrailingForeColor= 8421504 CurrentDate = 38622 End Begin VB.CommandButton Command7 BackColor = &H00FF00FF& Caption = "..." Enabled = 0 'False BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 4080 Style = 1 'Graphical TabIndex = 29 Top = 6840 Width = 375 End Begin VB.CommandButton Command6 BackColor = &H00FF00FF& Caption = "..." Enabled = 0 'False BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 4080 Style = 1 'Graphical TabIndex = 28 Top = 6360 Width = 375 End Begin MSComCtl2.MonthView MonthView2 Height = 2370 Left = 4890 TabIndex = 27 Top = 360 Visible = 0 'False Width = 2490 _ExtentX = 4392 _ExtentY = 4180 _Version = 393216 ForeColor = -2147483630 BackColor = 12632256 Appearance = 1 MonthBackColor = 16777152 StartOfWeek = 20774914 TitleBackColor = 8388736 TitleForeColor = 12648447 TrailingForeColor= 8421504 CurrentDate = 38621 End Begin MSComCtl2.MonthView MonthView1 Height = 2370 Left = 2400 TabIndex = 26 Top = 360 Visible = 0 'False Width = 2490 _ExtentX = 4392 _ExtentY = 4180 _Version = 393216 ForeColor = -2147483630 BackColor = 12632256 Appearance = 1 MonthBackColor = 16777152 StartOfWeek = 20774914 TitleBackColor = 8388736 TitleForeColor = 8454143 TrailingForeColor= 8421504 CurrentDate = 38621 End Begin VB.CommandButton Command5 BackColor = &H00FF00FF& Caption = "..." BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 4890 Style = 1 'Graphical TabIndex = 25 Top = 360 Width = 375 End Begin VB.CommandButton Command4 BackColor = &H00FF00FF& Caption = "..." BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 2400 Style = 1 'Graphical TabIndex = 24 Top = 360 Width = 375 End Begin VB.CommandButton Cmdprint BackColor = &H00FFFFC0& Caption = "พิมพ์" Enabled = 0 'False BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 855 Left = 10080 Picture = "Expdate.frx":074C Style = 1 'Graphical TabIndex = 23 Top = 4680 Visible = 0 'False Width = 1455 End Begin VB.Frame Frame2 BackColor = &H00C0C0C0& Caption = "เลือกประเภท" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00008000& Height = 975 Left = 5520 TabIndex = 21 Top = 0 Width = 2535 Begin VB.OptionButton Option2 BackColor = &H00C0C0C0& Caption = "ภาษาไทย" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 210 Left = 240 TabIndex = 22 Top = 600 Width = 2055 End Begin VB.OptionButton Option1 BackColor = &H00C0C0C0& Caption = "ภาษาต่างประเทศ" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 255 Left = 240 TabIndex = 3 Top = 240 Width = 1815 End End Begin VB.TextBox Text1 BackColor = &H00C0FFC0& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 375 Left = 820 Locked = -1 'True MaxLength = 10 TabIndex = 1 Top = 360 Width = 1575 End Begin VB.CommandButton cmdsave BackColor = &H00C0E0FF& Caption = "บันทึก" Enabled = 0 'False BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 855 Left = 10080 Picture = "Expdate.frx":0A56 Style = 1 'Graphical TabIndex = 18 Top = 6720 Width = 1455 End Begin VB.CommandButton cmdedit BackColor = &H00C0E0FF& Caption = "แก้ไข" Enabled = 0 'False BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 855 Left = 10080 Picture = "Expdate.frx":0E98 Style = 1 'Graphical TabIndex = 17 Top = 5760 Width = 1455 End Begin VB.TextBox Text8 BackColor = &H00C0FFFF& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 375 Left = 2760 Locked = -1 'True MaxLength = 10 TabIndex = 11 Top = 6840 Width = 1335 End Begin VB.TextBox Text7 BackColor = &H00C0FFFF& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 375 Left = 2760 Locked = -1 'True MaxLength = 10 TabIndex = 10 Top = 6360 Width = 1335 End Begin VB.TextBox Text5 Alignment = 1 'Right Justify BackColor = &H00C0FFFF& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 375 Left = 2760 TabIndex = 9 Top = 5880 Width = 975 End Begin VB.TextBox Text4 BackColor = &H00C0FFFF& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 375 Left = 2760 TabIndex = 8 Top = 5400 Width = 6495 End Begin VB.TextBox Text3 BackColor = &H00C0FFFF& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 375 Left = 2760 TabIndex = 7 Top = 4920 Width = 5175 End Begin VB.CommandButton Command3 BackColor = &H00C0E0FF& Caption = "Exit" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Left = 10680 MaskColor = &H00800000& Picture = "Expdate.frx":12DA Style = 1 'Graphical TabIndex = 6 Top = 120 Width = 1095 End Begin VB.CommandButton Command2 BackColor = &H00C0E0FF& Caption = "Clear" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Left = 9480 Picture = "Expdate.frx":171C Style = 1 'Graphical TabIndex = 5 Top = 120 Width = 1095 End Begin VB.CommandButton Command1 BackColor = &H00C0E0FF& Caption = "Search" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 735 Left = 8160 Picture = "Expdate.frx":1B5E Style = 1 'Graphical TabIndex = 4 Top = 120 Width = 1215 End Begin VB.TextBox Text2 BackColor = &H00C0FFC0& BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 375 Left = 3320 Locked = -1 'True MaxLength = 10 TabIndex = 2 Top = 360 Width = 1575 End Begin MSFlexGridLib.MSFlexGrid showjour Height = 3255 Left = 240 TabIndex = 19 Top = 1200 Width = 11295 _ExtentX = 19923 _ExtentY = 5741 _Version = 393216 Cols = 9 FixedCols = 0 BackColor = 12648447 ForeColor = 12582912 BackColorFixed = 12632256 BackColorSel = 8388608 ForeColorSel = 16777215 BackColorBkg = 12632256 FocusRect = 0 ScrollBars = 2 SelectionMode = 1 BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin VB.Label Label2 BackColor = &H00C0C0C0& Caption = "ถึง" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 255 Left = 3000 TabIndex = 20 Top = 480 Width = 255 End Begin VB.Label Label9 Alignment = 1 'Right Justify BackColor = &H00C0C0C0& Caption = "วันที่ครบอายุ" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 375 Left = 1200 TabIndex = 16 Top = 6840 Width = 1335 End Begin VB.Label Label8 Alignment = 1 'Right Justify BackColor = &H00C0C0C0& Caption = "วันที่ต่ออายุ" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 375 Left = 1440 TabIndex = 15 Top = 6360 Width = 1095 End Begin VB.Label Label5 Alignment = 1 'Right Justify BackColor = &H00C0C0C0& Caption = "ค่าสมาชิก/ปี" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 375 Left = 1080 TabIndex = 14 Top = 5880 Width = 1455 End Begin VB.Label Label4 Alignment = 1 'Right Justify BackColor = &H00C0C0C0& Caption = "ตัวแทน/ร้านค้า" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 375 Left = 960 TabIndex = 13 Top = 5400 Width = 1575 End Begin VB.Label Label3 Alignment = 1 'Right Justify BackColor = &H00C0C0C0& Caption = "รายชื่อวารสาร" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00800000& Height = 255 Left = 1080 TabIndex = 12 Top = 4920 Width = 1455 End Begin VB.Label Label1 Alignment = 1 'Right Justify BackColor = &H00C0C0C0& Caption = "วันที่" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 222 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H00C00000& Height = 255 Left = 240 TabIndex = 0 Top = 480 Width = 495 End End Attribute VB_Name = "expdate" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim Conn As New ADODB.Connection Dim listmagazine As New ADODB.Recordset Dim listmag_item As New ADODB.Recordset Dim magazinetb As New ADODB.Recordset Dim currencytb As New ADODB.Recordset Dim schpointer As String Dim linegrid As Integer Private Sub Cmdcancel_Click() schpointer = showjour.TextMatrix(showjour.Row, 6) Text3.Text = showjour.TextMatrix(showjour.Row, 0) Text4.Text = showjour.TextMatrix(showjour.Row, 4) Text5.Text = showjour.TextMatrix(showjour.Row, 3) Text7.Text = showjour.TextMatrix(showjour.Row, 5) Text8.Text = showjour.TextMatrix(showjour.Row, 1) Call lockinput Cmdedit.Enabled = True Cmdsave.Enabled = False Cmdcancel.Visible = False showjour.Enabled = True End Sub Private Sub Cmdedit_Click() Cmdcancel.Visible = True Cmdedit.Enabled = False Cmdsave.Enabled = True Command6.Enabled = True Command7.Enabled = True showjour.Enabled = False Call unlockinput Text5.SetFocus End Sub Private Sub Cmdprint_Click() Dim rowheight As Integer Dim yposition As Integer Dim lineprn As Integer Dim numprn As Integer Dim numpage As Integer If MsgBox("คุณต้องการพิมพ์ข้อมูลหรือไม่", vbInformation + vbOKCancel, "พิมพ์ข้อมูล") = vbOK Then numpage = 1 With Printer .FontName = "MS Sans Serif" .FontBold = True .FontSize = 18 .FontUnderline = True .CurrentX = 4000 .CurrentY = 700 Printer.Print "รายชื่อวารสารที่จะครบอายุสมาชิก" .CurrentX = 3850 .CurrentY = 700 + .TextHeight("ทดสอบ") + 10 .FontUnderline = False .FontSize = 16 Printer.Print "ระหว่างวันที่ " & Text1 & " ถึง " & Text2 .CurrentY = 700 + (.TextHeight("ทดสอบ") + 30) * 2 .CurrentX = 250 Printer.Print "ลำดับที่" .CurrentY = 700 + (.TextHeight("ทดสอบ") + 30) * 2 .CurrentX = 3000 Printer.Print "รายชื่อวารสาร" .CurrentY = 700 + (.TextHeight("ทดสอบ") + 30) * 2 .CurrentX = 6300 Printer.Print "วันครบอายุสมาชิก" .CurrentY = 700 + (.TextHeight("ทดสอบ") + 30) * 2 .CurrentX = 9000 Printer.Print "ฉบับล่าสุด" lineprn = 3 numprn = 1 Do While numprn < linegrid .FontBold = False .CurrentY = 700 + (.TextHeight("ทดสอบ") + 30) * lineprn .CurrentX = 410 Printer.Print numprn .CurrentY = 700 + (.TextHeight("ทดสอบ") + 30) * lineprn .CurrentX = 1100 Printer.Print showjour.TextMatrix(numprn, 0) .CurrentY = 700 + (.TextHeight("ทดสอบ") + 30) * lineprn .CurrentX = 6700 Printer.Print showjour.TextMatrix(numprn, 1) .CurrentY = 700 + (.TextHeight("ทดสอบ") + 30) * lineprn .CurrentX = 8000 Printer.Print showjour.TextMatrix(numprn, 2) lineprn = lineprn + 1 numprn = numprn + 1 If lineprn > 30 Then .CurrentY = 700 + (.TextHeight("ทดสอบ") + 30) * (lineprn + 1) .CurrentX = 500 .FontSize = 14 Printer.Print "วันที่พิมพ์ " & Format(Date, "dd/mm/yyyy") lineprn = 1 numpage = numpage + 1 .NewPage .FontSize = 16 .CurrentY = 500 .CurrentX = 10000 Printer.Print "หน้า " & numpage End If Loop .FontBold = True .FontUnderline = True .CurrentY = 700 + (.TextHeight("ทดสอบ") + 30) * (lineprn + 1) .CurrentX = 6500 Printer.Print "รวมทั้งสิ้น " & numprn - 1 & " รายชื่อ" .EndDoc End With End If End Sub Private Sub Cmdsave_Click() If MsgBox("ต้องการบันทึกข้อมูลหรือไม่", vbInformation + vbOKCancel, "บันทึกข้อมูล") = vbOK Then With magazinetb If .State = adStateOpen Then .Close .ActiveConnection = Conn .CursorType = adOpenForwardOnly .CursorLocation = adUseClient .LockType = adLockOptimistic .Open "select * from magazine where pointer='" & schpointer & "'" .Fields(14).Value = Trim(Text5.Text) .Fields(16).Value = Format(Text8.Text, "yyyy-mm-dd") .Fields(17).Value = Format(Text7.Text, "yyyy-mm-dd") .Update .Close End With showjour.TextMatrix(showjour.Row, 3) = Text5.Text showjour.TextMatrix(showjour.Row, 5) = Text7.Text showjour.TextMatrix(showjour.Row, 1) = Text8.Text MsgBox "บันทึกข้อมูลเรียบร้อยแล้ว", vbInformation + vbOKOnly, "ผลการบันทึกข้อมูล" Cmdedit.Enabled = True Cmdsave.Enabled = False Command6.Enabled = False Command7.Enabled = False Cmdcancel.Visible = False showjour.Enabled = True Call lockinput End If End Sub Private Sub Command1_Click() Dim strsql As String Dim jtype As String Dim jtypeEn As String Dim nrow As Integer Dim s_date As Date Dim e_date As Date If Option1.Value = True Then jtype = "J" End If If Option2.Value = True Then jtype = "I" 'jtypeTh = "K" 'jtypeEn = "L" End If s_date = Format(Text1.Text, "dd/mm/yyyy") e_date = Format(Text2.Text, "dd/mm/yyyy") linegrid = 1 strsql = strsql & "select magazine.Pointer,magazine.Magazine_Name,magazine.Price_Per_Year," strsql = strsql & "magazine.Order_Date,magazine.End_Date," strsql = strsql & "dealer.Publisher_Name from magazine,dealer " strsql = strsql & "where left(magazine.pointer,1) ='" & jtype & "' " strsql = strsql & "and magazine.receive_code='1' and magazine.Publisher_Code=dealer.Publisher_Code order by magazine.Magazine_Name" 'strsql = strsql & "and DateValue('" & s_date & "')<=DateValue(magazine.End_Date) " 'strsql = strsql & "and DateValue('" & e_date & "')>=DateValue(magazine.End_Date) order by magazine.End_Date" With listmagazine If .State = adStateOpen Then .Close .ActiveConnection = Conn .CursorType = adOpenForwardOnly .CursorLocation = adUseClient .Open strsql Do While Not .EOF If DateValue(s_date) <= DateValue(Format(listmagazine.Fields(4).Value, "dd/mm/yyyy")) And DateValue(e_date) >= DateValue(Format(listmagazine.Fields(4).Value, "dd/mm/yyyy")) Then showjour.Rows = showjour.Rows + 1 showjour.TextMatrix(linegrid, 0) = .Fields(1).Value showjour.TextMatrix(linegrid, 1) = Format(.Fields(4).Value, "dd/mm/yyyy") showjour.TextMatrix(linegrid, 3) = .Fields(2).Value showjour.TextMatrix(linegrid, 4) = .Fields(5).Value showjour.TextMatrix(linegrid, 5) = Format(.Fields(3).Value, "dd/mm/yyyy") showjour.TextMatrix(linegrid, 6) = .Fields(0).Value 'showjour.TextMatrix(linegrid, 7) = .Fields(7).Value 'showjour.TextMatrix(linegrid, 8) = .Fields(0).Value With listmag_item If .State = adStateOpen Then .Close .ActiveConnection = Conn .CursorType = adOpenForwardOnly .CursorLocation = adUseClient .Open " select descriptionitem from tranfile where pointer='" & listmagazine.Fields(0).Value & "' order by to_days(daily) DESC" If Not .EOF Then showjour.TextMatrix(linegrid, 2) = .Fields(0).Value .Close End With showjour.Row = 1 linegrid = linegrid + 1 End If .MoveNext Loop If linegrid = 1 Then MsgBox "ไม่พบรายชื่อวารสารที่จะครบอายุสมาชิกในช่วงเวลานี้", vbInformation + vbOKOnly, "ผลการตรวจเช็ค" Exit Sub End If If showjour.Rows < 11 Then showjour.Rows = 12 .Close End With cmdprint.Enabled = True Command1.Enabled = False End Sub Private Sub Command2_Click() Dim i As Integer showjour.Rows = 11 For i = 1 To 10 showjour.TextMatrix(i, 0) = "" showjour.TextMatrix(i, 1) = "" showjour.TextMatrix(i, 2) = "" showjour.TextMatrix(i, 3) = "" showjour.TextMatrix(i, 4) = "" showjour.TextMatrix(i, 5) = "" showjour.TextMatrix(i, 6) = "" showjour.TextMatrix(i, 7) = "" Next i showjour.Row = 1 showjour.Rows = 2 showjour.HighLight = flexHighlightAlways Call lockinput Text3.Text = "" Text4.Text = "" Text5.Text = "" Text7.Text = "" Text8.Text = "" Text1.Text = Format(Date, "dd/mm/yyyy") Text2.Text = Format(Date, "dd/mm/yyyy") Cmdsave.Enabled = False Cmdedit.Enabled = False cmdprint.Enabled = False Command1.Enabled = True End Sub Private Sub Command3_Click() Conn.Close Set Conn = Nothing Unload Me End Sub Private Sub Command4_Click() MonthView1.Value = Now() MonthView1.Visible = True End Sub Private Sub Command5_Click() MonthView2.Value = Now() MonthView2.Visible = True End Sub Private Sub Command6_Click() MonthView3.Value = Now() MonthView3.Visible = True End Sub Private Sub Command7_Click() MonthView4.Value = Text8.Text MonthView4.Visible = True End Sub Private Sub Form_Load() Dim strsql As String showjour.ColWidth(0) = 6300 showjour.ColWidth(1) = 1500 showjour.ColWidth(2) = 3150 showjour.TextMatrix(0, 0) = " รายชื่อวารสาร" showjour.TextMatrix(0, 1) = " วันที่ครบอายุ" showjour.TextMatrix(0, 2) = " ฉบับล่าสุดที่ได้รับ" Call lockinput Set Conn = New ADODB.Connection Conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _ & "SERVER=192.168.1.15;" _ & "DATABASE=magazine;" _ & "UID=chaiya;" _ & "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384 Conn.CursorLocation = adUseClient Conn.Mode = adModeUnknown Conn.Open Text1.Text = Format(Date, "dd/mm/yyyy") Text2.Text = Format(Date, "dd/mm/yyyy") Call Text1_Click End Sub Private Sub MonthView1_DateClick(ByVal DateClicked As Date) Text1.Text = Format(DateClicked, "dd/mm/yyyy") MonthView1.Visible = False End Sub Private Sub MonthView2_DateClick(ByVal DateClicked As Date) Text2.Text = Format(DateClicked, "dd/mm/yyyy") MonthView2.Visible = False End Sub Private Sub MonthView3_DateClick(ByVal DateClicked As Date) Text7.Text = Format(DateClicked, "dd/mm/yyyy") Text8.Text = Format(DateAdd("m", 11, DateClicked), "dd/mm/yyyy") MonthView3.Visible = False End Sub Private Sub MonthView4_DateClick(ByVal DateClicked As Date) Text8.Text = Format(DateClicked, "dd/mm/yyyy") MonthView4.Visible = False End Sub Private Sub showjour_Click() schpointer = showjour.TextMatrix(showjour.Row, 6) Text3.Text = showjour.TextMatrix(showjour.Row, 0) Text4.Text = showjour.TextMatrix(showjour.Row, 4) Text5.Text = showjour.TextMatrix(showjour.Row, 3) Text7.Text = showjour.TextMatrix(showjour.Row, 5) Text8.Text = showjour.TextMatrix(showjour.Row, 1) Call lockinput Cmdedit.Enabled = True Cmdsave.Enabled = False End Sub Sub lockinput() Text3.Enabled = False Text3.BackColor = &HC0FFFF Text4.Enabled = False Text4.BackColor = &HC0FFFF Text5.Enabled = False Text5.BackColor = &HC0FFFF Text7.Enabled = False Text7.BackColor = &HC0FFFF Text8.Enabled = False Text8.BackColor = &HC0FFFF End Sub Sub unlockinput() Text3.BackColor = &HC0FFFF Text4.BackColor = &HC0FFFF Text5.Enabled = True Text5.BackColor = &HC0FFFF Text7.Enabled = True Text7.BackColor = &HC0FFFF Text8.Enabled = True Text8.BackColor = &HC0FFFF End Sub Private Sub Text1_Click() 'Text1.SelStart = 0 'Text1.SelLength = Len(Text1.Text) End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) Dim character As String character = "0123456789" KeyAscii = Asc(Chr(KeyAscii)) If KeyAscii > 26 Then If Len(Trim(Text1)) = 2 Or Len(Trim(Text1)) = 5 Then Text1.Text = Text1.Text + "/" Text1.SelStart = Len(Trim(Text1.Text)) Else If InStr(character, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End If End If End Sub Private Sub Text2_Click() 'Text2.SelStart = 0 'Text2.SelLength = Len(Text2.Text) End Sub Private Sub Text2_KeyPress(KeyAscii As Integer) Dim character As String character = "0123456789" KeyAscii = Asc(Chr(KeyAscii)) If KeyAscii > 26 Then If Len(Trim(Text2)) = 2 Or Len(Trim(Text2)) = 5 Then Text2.Text = Text2.Text + "/" Text2.SelStart = Len(Trim(Text2.Text)) Else If InStr(character, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End If End If End Sub Private Sub Text5_Click() Text5.SelStart = 0 Text5.SelLength = Len(Text5.Text) End Sub Private Sub Text7_Click() Text7.SelStart = 0 Text7.SelLength = Len(Text7.Text) End Sub Private Sub Text7_KeyPress(KeyAscii As Integer) Dim character As String character = "0123456789" KeyAscii = Asc(Chr(KeyAscii)) If KeyAscii > 26 Then If Len(Trim(Text7)) = 2 Or Len(Trim(Text7)) = 5 Then Text7.Text = Text7.Text + "/" Text7.SelStart = Len(Trim(Text7.Text)) Else If InStr(character, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End If End If End Sub Private Sub Text8_Click() Text8.SelStart = 0 Text8.SelLength = Len(Text8.Text) End Sub Private Sub Text8_KeyPress(KeyAscii As Integer) Dim character As String character = "0123456789" KeyAscii = Asc(Chr(KeyAscii)) If KeyAscii > 26 Then If Len(Trim(Text8)) = 2 Or Len(Trim(Text8)) = 5 Then Text8.Text = Text8.Text + "/" Text8.SelStart = Len(Trim(Text8.Text)) Else If InStr(character, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End If End If End Sub