几年前出于兴趣写的。将以下vbs代码另存为文件,双击后即可听到语音报时。
Dim a,b,c,d,e,f,g
Function FormateTime(sendTime,Para) '格式化时间
select case Para
case "1"
sendTime = Right("00" & Hour(sendTime),2) & ":"& right( "00" & minute(sendTime),2) & ":"& right( "00" & Second(sendTime),2)
end select
FormateTime = SendTime
end Function
Function FormateDate(sendTime,Para) '格式化日期
select case Para
Rem YYYY年MM月DD日
case "1"
sendTime = year(sendTime) & "年"& right( "00" & month(sendTime),2) & "月"& right( "00" & day(sendTime),2)& "日 "
End select
FormateDate = SendTime
end Function
'MsgBox FormateDate(date(), "1")
a = Left(FormateTime(Time(), "1"),2)
b = "飞阳早上好,现在是,"
c = "飞阳上午好,现在是,"
d = "飞阳中午好,现在是,"
e = "飞阳下午好,现在是,"
f = "飞阳晚上好,现在是,"
g = ","&WeekdayName(Weekday(Date))
Set objVoice = CreateObject("SAPI.SpVoice")
objVoice.Rate = -2
objVoice.Volume = 60
If a >= 0 And a <= 8 Then
objVoice.Speak b&Time&g
End If
If a >= 9 And a <= 11 Then
objVoice.Speak c&Time&g
End If
If a >= 12 And a <= 14 Then
objVoice.Speak d&Time&g
End If
If a >= 15 And a <= 18 Then
objVoice.Speak e&Time&g
End If
If a > 19 And a <= 23 Then
objVoice.Speak f&Time&g
End If