做的一个学校考试 打铃程序,请搞手指点一下!!
Dim timelist2()Dim timelist3()
Dim timelist4()
Dim timelist5()
Dim timelist6()
Dim timelist7()
Dim timelist8()
Dim timelist9()
Dim timelist10()
Dim timelist11()
Dim timelist12()
Dim i1 As Integer
Dim i2 As Integer
Dim i3 As Integer
Dim i4 As Integer
Dim i5 As Integer
Dim i6 As Integer
Dim i7 As Integer
Dim i8 As Integer
Dim i9 As Integer
Dim i10 As Integer
Dim i11 As Integer
Dim i12 As Integer
Private Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
Private Sub Form_Load()
If GetDriveType(dri) <> 5 Then
If Dir(App.Path & "\test.xls") <> "" Then
MsgBox "恭禧:Test.xls配置文件已经存在,不需要再创建了", vbInformation, "文件搜索提示····"
Timer1.Enabled = True
Else: MsgBox "不存在 Test.xls 这个配置文件,", vbInformation, "文件搜索提示····"
Timer1.Enabled = False
End If
End If
End Sub
Private Sub Timer1_Timer()
Label2.Caption = "现在时间是:" & Time
Label3.Caption = "今天的日期是:" & Date
Label5.Caption = "今天是星期:" & Val(Weekday(Date)) - 1
ReDim timelist1(20) '重新定义数组
ReDim timelist2(20) '重新定义数组
ReDim timelist3(20) '重新定义数组
ReDim timelist4(20) '重新定义数组
ReDim timelist5(20) '重新定义数组
ReDim timelist6(20) '重新定义数组
ReDim timelist7(20) '重新定义数组
ReDim timelist8(20) '重新定义数组
ReDim timelist9(20) '重新定义数组
ReDim timelist10(20) '重新定义数组
ReDim timelist11(20) '重新定义数组
ReDim timelist12(20) '重新定义数组
'以两节课为例,即有四个时间点,保存在下面的数组中即可
'下是对 EXCEL 的调用
Dim excel As Object
Set excel = CreateObject("excel.application") '设定 excel API
'--------------这上面可不看 照抄
excel.Workbooks.Open App.Path & "\test.xls" 'P.s请先自己创立 'excel 开启
excel.Visible = False 'excel 显示 or 隐藏 (True of False
'Dim i1 As Integer '时间变量
i1 = 0
For i1 = 0 To UBound(timelist1)
If Now() = timelist1(i1) Then
= "stop"
= "open"
MMControl1.DeviceType = "mp3audio"
MMControl1.PlayEnabled = True
= "prev"
= "play"
Exit For
timelist1 = Array(CDate(excel.cells(3, 3)), CDate(excel.cells(4, 3)), CDate(excel.cells(5, 3)), CDate(excel.cells(6, 3)) _
, CDate(excel.cells(7, 3)), CDate(excel.cells(8, 3)), CDate(excel.cells(9, 3)), CDate(excel.cells(10, 3)) _
, CDate(excel.cells(11, 3)), CDate(excel.cells(12, 3)), CDate(excel.cells(13, 3)), CDate(excel.cells(14, 3)) _
, CDate(excel.cells(15, 3)), CDate(excel.cells(16, 3)), CDate(excel.cells(17, 3)), CDate(excel.cells(18, 3)) _
, CDate(excel.cells(19, 3)), CDate(excel.cells(20, 3)))
MMControl1.FileName = App.Path & "\铃声\考前30分钟.mp3" '指定铃声文件
End If
'If Weekday(Date) = "5,6" Then ‘ 排除星六星期天或不考试的日期
' MMControl1.CanPlay = False
' End If
Next i1
'Dim i2 As Integer '时间变量
i2 = 0
For i2 = 0 To UBound(timelist2)
If Now() = timelist2(i2) Then
= "stop"
= "open"
MMControl1.DeviceType = "mp3audio"
MMControl1.PlayEnabled = True
= "prev"
= "play"
Exit For
timelist2 = Array(CDate(excel.cells(3, 4)), CDate(excel.cells(4, 4)), CDate(excel.cells(5, 4)), CDate(excel.cells(6, 4)) _
, CDate(excel.cells(7, 4)), CDate(excel.cells(8, 4)), CDate(excel.cells(9, 4)), CDate(excel.cells(10, 4)) _
, CDate(excel.cells(11, 4)), CDate(excel.cells(12, 4)), CDate(excel.cells(13, 4)), CDate(excel.cells(14, 4)) _
, CDate(excel.cells(15, 4)), CDate(excel.cells(16, 4)), CDate(excel.cells(17, 4)), CDate(excel.cells(18, 4)) _
, CDate(excel.cells(19, 4)), CDate(excel.cells(20, 4)))
MMControl1.FileName = App.Path & "\铃声\考前20分钟.mp3" '指定铃声文件
End If
Next i2
i3 = 0
For i3 = 0 To UBound(timelist3)
If Now() = timelist3(i3) Then
= "stop"
= "open"
MMControl1.DeviceType = "mp3audio"
MMControl1.PlayEnabled = True
= "prev"
= "play"
Exit For
timelist3 = Array(CDate(excel.cells(3, 5)), CDate(excel.cells(4, 5)), CDate(excel.cells(5, 5)), CDate(excel.cells(6, 5)) _
, CDate(excel.cells(7, 5)), CDate(excel.cells(8, 5)), CDate(excel.cells(9, 5)), CDate(excel.cells(10, 5)) _
, CDate(excel.cells(11, 5)), CDate(excel.cells(12, 5)), CDate(excel.cells(13, 5)), CDate(excel.cells(14, 5)) _
, CDate(excel.cells(15, 5)), CDate(excel.cells(16, 5)), CDate(excel.cells(17, 5)), CDate(excel.cells(18, 5)) _
, CDate(excel.cells(19, 5)), CDate(excel.cells(20, 5)))
MMControl1.FileName = App.Path & "\铃声\预备铃.mp3" '指定铃声文件
End If
Next i3
i4 = 0
For i4 = 0 To UBound(timelist4)
If Now() = timelist4(i4) Then
= "stop"
= "open"
MMControl1.DeviceType = "mp3audio"
MMControl1.PlayEnabled = True
= "prev"
= "play"
Exit For
timelist4 = Array(CDate(excel.cells(3, 6)), CDate(excel.cells(4, 6)), CDate(excel.cells(5, 6)), CDate(excel.cells(6, 6)) _
, CDate(excel.cells(7, 6)), CDate(excel.cells(8, 6)), CDate(excel.cells(9, 6)), CDate(excel.cells(10, 6)) _
, CDate(excel.cells(11, 6)), CDate(excel.cells(12, 6)), CDate(excel.cells(13, 6)), CDate(excel.cells(14, 6)) _
, CDate(excel.cells(15, 6)), CDate(excel.cells(16, 6)), CDate(excel.cells(17, 6)), CDate(excel.cells(18, 6)) _
, CDate(excel.cells(19, 6)), CDate(excel.cells(20, 6)))
MMControl1.FileName = App.Path & "\铃声\拆封哨.mp3" '指定铃声文件
End If
Next i4
i5 = 0
For i5 = 0 To UBound(timelist5)
If Now() = timelist5(i5) Then
= "stop"
= "open"
MMControl1.DeviceType = "mp3audio"
MMControl1.PlayEnabled = True
= "prev"
= "play"
Exit For
timelist4 = Array(CDate(excel.cells(3, 7)), CDate(excel.cells(4, 7)), CDate(excel.cells(5, 7)), CDate(excel.cells(6, 7)) _
, CDate(excel.cells(7, 7)), CDate(excel.cells(8, 7)), CDate(excel.cells(9, 7)), CDate(excel.cells(10, 7)) _
, CDate(excel.cells(11, 7)), CDate(excel.cells(12, 7)), CDate(excel.cells(13, 7)), CDate(excel.cells(14, 7)) _
, CDate(excel.cells(15, 7)), CDate(excel.cells(16, 7)), CDate(excel.cells(17, 7)), CDate(excel.cells(18, 7)) _
, CDate(excel.cells(19, 7)), CDate(excel.cells(20, 7)))
MMControl1.FileName = App.Path & "\铃声\发卷哨.mp3" '指定铃声文件
End If
Next i5
i6 = 0
For i6 = 0 To UBound(timelist6)
If Now() = timelist6(i6) Then
= "stop"
= "open"
MMControl1.DeviceType = "mp3audio"
MMControl1.PlayEnabled = True
= "prev"
= "play"
Exit For
timelist6 = Array(CDate(excel.cells(3, 8)), CDate(excel.cells(4, 8)), CDate(excel.cells(5, 8)), CDate(excel.cells(6, 8)) _
, CDate(excel.cells(7, 8)), CDate(excel.cells(8, 8)), CDate(excel.cells(9, 8)), CDate(excel.cells(10, 8)) _
, CDate(excel.cells(11, 8)), CDate(excel.cells(12, 8)), CDate(excel.cells(13, 8)), CDate(excel.cells(14, 8)) _
, CDate(excel.cells(15, 8)), CDate(excel.cells(16, 8)), CDate(excel.cells(17, 8)), CDate(excel.cells(18, 8)) _
, CDate(excel.cells(19, 8)), CDate(excel.cells(20, 8)))
MMControl1.FileName = App.Path & "\铃声\开考铃.mp3" '指定铃声文件
End If
Next i6
i7 = 0
For i7 = 0 To UBound(timelist7)
If Now() = timelist7(i7) Then
= "stop"
= "open"
MMControl1.DeviceType = "mp3audio"
MMControl1.PlayEnabled = True
= "prev"
= "play"
Exit For
timelist7 = Array(CDate(excel.cells(3, 9)), CDate(excel.cells(4, 9)), CDate(excel.cells(5, 9)), CDate(excel.cells(6, 9)) _
, CDate(excel.cells(7, 9)), CDate(excel.cells(8, 9)), CDate(excel.cells(9, 9)), CDate(excel.cells(10, 9)) _
, CDate(excel.cells(11, 9)), CDate(excel.cells(12, 9)), CDate(excel.cells(13, 9)), CDate(excel.cells(14, 9)) _
, CDate(excel.cells(15, 9)), CDate(excel.cells(16, 9)), CDate(excel.cells(17, 9)), CDate(excel.cells(18, 9)) _
, CDate(excel.cells(19, 9)), CDate(excel.cells(20, 9)))
MMControl1.FileName = App.Path & "\铃声\界线哨.mp3" '指定铃声文件
End If
Next i7
i8 = 0
For i8 = 0 To UBound(timelist8)
If Now() = timelist8(i8) Then
= "stop"
= "open"
MMControl1.DeviceType = "mp3audio"
MMControl1.PlayEnabled = True
= "prev"
= "play"
Exit For
timelist8 = Array(CDate(excel.cells(3, 3)), CDate(excel.cells(4, 3)), CDate(excel.cells(5, 3)), CDate(excel.cells(6, 3)) _
, CDate(excel.cells(7, 10)), CDate(excel.cells(8, 10)), CDate(excel.cells(9, 10)), CDate(excel.cells(10, 10)) _
, CDate(excel.cells(11, 10)), CDate(excel.cells(12, 10)), CDate(excel.cells(13, 10)), CDate(excel.cells(14, 10)) _
, CDate(excel.cells(15, 10)), CDate(excel.cells(16, 10)), CDate(excel.cells(17, 10)), CDate(excel.cells(18, 10)) _
, CDate(excel.cells(19, 10)), CDate(excel.cells(20, 10)))
MMControl1.FileName = App.Path & "\铃声\提醒哨.mp3" '指定铃声文件
End If
Next i8
i9 = 0
For i9 = 0 To UBound(timelist9)
If Now() = timelist9(i9) Then
= "stop"
= "open"
MMControl1.DeviceType = "mp3audio"
MMControl1.PlayEnabled = True
= "prev"
= "play"
Exit For
timelist9 = Array(CDate(excel.cells(3, 11)), CDate(excel.cells(4, 11)), CDate(excel.cells(5, 11)), CDate(excel.cells(6, 11)) _
, CDate(excel.cells(7, 11)), CDate(excel.cells(8, 11)), CDate(excel.cells(9, 11)), CDate(excel.cells(10, 11)) _
, CDate(excel.cells(11, 11)), CDate(excel.cells(12, 11)), CDate(excel.cells(13, 11)), CDate(excel.cells(14, 11)) _
, CDate(excel.cells(15, 11)), CDate(excel.cells(16, 11)), CDate(excel.cells(17, 11)), CDate(excel.cells(18, 11)) _
, CDate(excel.cells(19, 11)), CDate(excel.cells(20, 11)))
MMControl1.FileName = App.Path & "\铃声\终了铃.mp3" '指定铃声文件
End If
Next i9
'excel.ActiveWorkbook.Save 'excel 存档
excel.quit
End Sub
为什么 到了时间不打铃呢···〈〉〈〉请搞手指点