如何在不使用查询的情况下比较时间? 这是为了解冲突 公共类TimeNo用于将时间转换为long 还有一个错误的代码,它表示byref参数类型不匹配错误
Function getConflict() As Boolean
Me.lstSchedules.ListItems.clear
Dim currentStartTime, currentEndTime, startTime, endTime As Date
Set rs = Nothing
currentStartTime = Me.cboTime.Text
currrentendtime = Me.cboEnd.Text
With rs
.CursorLocation = adUseClient
.Open "select * from tblSecSched where Sections = '" & Me.cboSection.Text & "' and [Day] = '" & Me.cboDay.Text & "' and SchoolLevel = '" & Me.cboSchoolLevel.Text & "' and YearLevel = '" & Me.cboYearLevel.Text & "' and SchoolYear = '" & sH & "'", cs, 1, 2
If .RecordCount > 0 Then
getConflict = False
Do While Not .EOF
startTime = CDate(!TimeIn)
endTime = CDate(!TimeOut)
If ((TimeNo(startTime) < TimeNo(currentStartTime)) And (TimeNo(endTime) > TimeNo(currentStartTime))) Or ((TimeNo(startTime) < TimeNo(currentEndTime)) And (TimeNo(endTime) > TimeNo(currentEndTime))) Then
MsgBox "Schedule Conflict", vbExclamation, "ERROR"
Me.lstSchedules.ListItems.clear
With Me.lstSchedules.ListItems.Add(, , !SchoolLevel)
.SubItems(1) = rs!YearLevel
.SubItems(2) = rs!Sections
.SubItems(3) = rs!Subject
.SubItems(4) = rs!TimeIn
.SubItems(5) = rs!TimeOut
.SubItems(6) = sH
End With
End If
.MoveNext
Loop
Else
getConflict = True
End If
End With
End Function
Public Function TimeNo(Time As String) As Long
TimeNo = CLng(Replace(Format(Time, "hhnnss"), ":", ""))
End Function