我想进行数据库查询以检索假期日期并与 msflexgrid 列中的天数进行比较。如果有比赛,我想用红色标记。
Private Sub Text1_LostFocus(Index As Integer)
Select Case Index
Case 1
Grid.Clear
fechainicial = "01/" & Text1(1) & "/" & Text1(0)
numdias = DaysInMonth(fechainicial)
Grid.Cols = numdias + 2
For i = 0 To numdias
With Grid
.Redraw = False
.Rows = 4
.FixedRows = 2
For ii = 0 To .Rows - 1
.RowHeight(ii) = 300
Next
.RowHeight(2) = 0
.ColWidth(0) = 300
.ColWidth(i + 1) = 450
If i <= .Cols - 3 Then
.TextMatrix(0, i + 1) = Format(CStr(FormatDateTime(fechainicial + i, vbShortDate)), "d")
.TextMatrix(1, i + 1) = UCase(Format(i + 1 & "/" & Text1(1) & "/" & Text1(0), "ddd"))
End If
If Weekday(fechainicial + i, vbMonday) = 7 Then
numc = i + 1
fila = 1
.Col = numc
.Row = fila
.CellForeColor = vbRed
.TextMatrix(2, i + 1) = "D"
End If
.ColWidth(.Cols - 1) = 900
.TextMatrix(0, .Cols - 1) = "HORAS"
.Col = 1
.Row = 3
.Redraw = True
End With
Next i
'End If
End Select
End Sub
数据库表:FESTIVOS,字段:id,fecha,descripcion