vbs版的语音报时程序

 几年前出于兴趣写的。将以下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


 

转载于:https://my.oschina.net/u/2391658/blog/708815

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值