Private Sub ShowMSFG()
Dim n As String
Dim colordate As String
Dim sqlmsfg As String 'ประกาศค่าตัวแปร
Call formatmsfg
sqlmsfg = "SELECT * FROM Car ORDER BY ID ASC"
Set rs = conndb.Execute(sqlmsfg)
If rs.EOF = True Then 'ตรวจสอบว่ามีข้อมูลหรือไม่
' Call removemsfg
Else
'ลบข้อมูลในตารางดาด้ากิลทั้งหมด
Call RemoveMSFG
'แสดงข้อมูลลงในดาต้ากิลทีละแถวโดยเริ่มนับจาก N=0
With MSFlexGrid1
n = 1
Dim clcol As Integer
Dim i As Integer
clcol = 0
If clcol Mod 2 = 0 Then
For i = 1 To 15
.Col = i
.Row = clcol
Next i
End If
Do
.Rows = .Rows + 1
.TextMatrix(n, 0) = rs("ID")
.TextMatrix(n, 1) = rs("ID_EM")
.TextMatrix(n, 2) = rs("ID_IN")
.TextMatrix(n, 3) = rs("Name")
.TextMatrix(n, 4) = rs("Lastname")
.TextMatrix(n, 5) = rs("Name2")
.TextMatrix(n, 6) = rs("Lastname2")
.TextMatrix(n, 7) = rs("Address")
.TextMatrix(n, 8) = rs("Address2")
.TextMatrix(n, 9) = rs("Car_ID")
.TextMatrix(n, 10) = rs("Brand")
.TextMatrix(n, 11) = rs("Model")
.TextMatrix(n, 12) = rs("Car_Type")
.TextMatrix(n, 13) = rs("Car_Status")
.TextMatrix(n, 14) = rs("Date_IN")
.TextMatrix(n, 15) = rs("Date_OUT")
If rs("Date_OUT") >= Date + 31 Then
.CellBackColor = RGB(238, 0, 0)
.TextMatrix(n, 15) = rs("Date_OUT")
Else
.CellBackColor = RGB(0, 255, 0)
End If
n = n + 1
rs.MoveNext
Loop Until rs.EOF = True
End With
End If
Tag : .NET, VB.NET, VS 2005 (.NET 2.x), VS 2008 (.NET 3.x)
Private Sub ShowMSFG()
Dim n As String
Dim dateoutt As String
Dim sqlmsfg As String 'ประกาศค่าตัวแปร
Call formatmsfg
sqlmsfg = "SELECT * FROM Car ORDER BY ID ASC"
Set rs = conndb.Execute(sqlmsfg)
If rs.EOF = True Then 'ตรวจสอบว่ามีข้อมูลหรือไม่
' Call removemsfg
Else
'ลบข้อมูลในตารางดาด้ากิลทั้งหมด
Call RemoveMSFG
'แสดงข้อมูลลงในดาต้ากิลทีละแถวโดยเริ่มนับจาก N=0
With MSFlexGrid1
n = 1
dateoutt = Date + 31
Dim clcol As Integer
Dim i As Integer
clcol = 0
If clcol Mod 2 = 0 Then
For i = 1 To 15
.Col = i
.Row = clcol
Next i
End If
Do
.Rows = .Rows + 1
.TextMatrix(n, 0) = rs("ID")
.TextMatrix(n, 1) = rs("ID_EM")
.TextMatrix(n, 2) = rs("ID_IN")
.TextMatrix(n, 3) = rs("Name")
.TextMatrix(n, 4) = rs("Lastname")
.TextMatrix(n, 5) = rs("Name2")
.TextMatrix(n, 6) = rs("Lastname2")
.TextMatrix(n, 7) = rs("Address")
.TextMatrix(n, 8) = rs("Address2")
.TextMatrix(n, 9) = rs("Car_ID")
.TextMatrix(n, 10) = rs("Brand")
.TextMatrix(n, 11) = rs("Model")
.TextMatrix(n, 12) = rs("Car_Type")
.TextMatrix(n, 13) = rs("Car_Status")
.TextMatrix(n, 14) = rs("Date_IN")
.TextMatrix(n, 15) = rs("Date_OUT")
If rs("Date_OUT") >= dateoutt Then
.CellBackColor = RGB(238, 0, 0)
.TextMatrix(n, 15) = rs("Date_OUT")
.Row = .Row + 1
Else
.CellBackColor = RGB(0, 255, 0)
.TextMatrix(n, 15) = rs("Date_OUT")
.Row = .Row + 1
End If
n = n + 1
rs.MoveNext
Loop Until rs.EOF = True
End With
End If
End Sub