7,763
社区成员
发帖
与我相关
我的任务
分享
Dim strTimeList(1 To 10) As Date
Private Sub Form_Load()
Call ReadTimeList
Timer1.Interval = 10000
Timer1.Enabled = True
End Sub
Private Sub ReadTimeList()
Dim i As Integer
Dim xlapp1 As Excel.Application
Dim xlbook1 As Excel.Workbook
Dim xlsheet1 As Excel.Worksheet
Set xlapp1 = CreateObject("Excel.Application")
Set xlbook1 = xlapp1.Workbooks.Open("d:\timelist.xls")
Set xlsheet1 = xlbook1.Worksheets(1)
For i = 1 To 10
strTimeList(i) = xlsheet1.Cells(i + 1, 2)
Next i
xlapp1.Quit
Set xlapp1 = Nothing
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
Dim xlapp1 As Excel.Application
Dim xlbook1 As Excel.Workbook
Dim xlsheet1 As Excel.Worksheet
For i = 1 To 10
If Format(Time, "hh:mm") = Format(strTimeList(i), "hh:mm") Then
Set xlapp1 = CreateObject("Excel.Application")
Set xlbook1 = xlapp1.Workbooks.Open("d:\timelist.xls")
Set xlsheet1 = xlbook1.Worksheets(1)
xlsheet1.Cells(i + 1, 3) = Text1.Text
xlbook1.Save
xlapp1.Quit
Set xlapp1 = Nothing
End If
Next i
End Sub
Dim ArrTxt(144) As String '记录一天内24*6个整十 分钟 文本信息
Private Sub Timer1_Timer()
If blnHG = True Then '根据你实际的情况来判定,如果合格则为true,否则false
Text1 = Val(Text1) + 1
End If
' ArrTxt(Hour(FormatDateTime(Now, vbLongTime))) = Trim$(Text1.Text)
If Hour(Now) = 0 Then '0:00-1:00
ArrTxt(Minute(Now) / 10) = Trim$(Text1.Text)
Else '1:00-23:59
ArrTxt((Hour(Now) - 1) * 6 + Minute(Now) / 10) = Trim$(Text1.Text)
End If
Me.Refresh '刷新窗体
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
Static strMemoryTime As Date
With Spreadsheet1
If Format(Time, "hh:mm") = strMemoryTime Then
Exit Sub
Else
strMemoryTime = Format(Time, "hh:mm")
For i = 1 To 10
If Format(Time, "hh:mm") = Format(.Cells(i + 1, 1), "hh:mm") Then
.Cells(i + 1, 2) = Text1.Text
End If
Next i
End If
End With
End Sub
Dim strTimeList(1 To 10) As Date
Private Sub Form_Load()
Call ReadTimeList
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub ReadTimeList()
Dim i As Integer
Dim xlapp1 As Excel.Application
Dim xlbook1 As Excel.Workbook
Dim xlsheet1 As Excel.Worksheet
Set xlapp1 = CreateObject("Excel.Application")
Set xlbook1 = xlapp1.Workbooks.Open("d:\timelist.xls")
Set xlsheet1 = xlbook1.Worksheets(1)
For i = 1 To 10
strTimeList(i) = xlsheet1.Cells(i + 1, 2)
Next i
xlapp1.Quit
Set xlapp1 = Nothing
End Sub
Private Sub Timer1_Timer()
Dim i As Integer
Dim xlapp1 As Excel.Application
Dim xlbook1 As Excel.Workbook
Dim xlsheet1 As Excel.Worksheet
Static strMemoryTime As Date
If Format(Time, "hh:mm") = strMemoryTime Then
Exit Sub
Else
strMemoryTime = Format(Time, "hh:mm")
For i = 1 To 10
If Format(Time, "hh:mm") = Format(strTimeList(i), "hh:mm") Then
Set xlapp1 = CreateObject("Excel.Application")
Set xlbook1 = xlapp1.Workbooks.Open("d:\timelist.xls")
Set xlsheet1 = xlbook1.Worksheets(1)
xlsheet1.Cells(i + 1, 3) = Text1.Text
xlbook1.Save
xlapp1.Quit
Set xlapp1 = Nothing
End If
Next i
End If
End Sub
Dim blnHG As Boolean '是否合格
Dim ArrTxt(24) As String '记录一天24小时的整点文本信息
Private Sub Timer1_Timer()
If blnHG = True Then '根据你实际的情况来判定,如果合格则为true,否则false
Text1 = Val(Text1) + 1
End If
ArrTxt(Hour(FormatDateTime(Now, vbLongTime))) = Trim$(Text1.Text)
Me.Refresh '刷新窗体
End Sub
Private Sub Command2_Click()
If ArrTxt(9) <> "" Then '现在是17点,你可以测试17点的情况 ArrTxt(17)
Debug.Print ArrTxt(9)
Else
Debug.Print "0"
End If
End Sub