使用股指最新行情的时间跟现在的时间比较,超过30秒就提醒。
Sub APP1
Set Report1=MarketData.GetReportData("IF00","ZJ")
StockTime=Report1.Date
TimeSpace=DateDiff("s",Cdate(Now),StockTime)
if abs(TimeSpace)>30 then
Application.MsgOut "请注意,行情数据已经超过30秒没有更新了!"
Exit Sub
end if
End Sub
Sub APP1
Set Report1=MarketData.GetReportData("IF00","ZJ")
StockTime=Report1.Date
TimeSpace=DateDiff("s",Cdate(Now),StockTime)
if abs(TimeSpace)>30 then
Application.MsgOut "请注意,行情数据已经超过30秒没有更新了!"
Exit Sub
end if
End Sub
如果还用pel语言,可以是使用time和currenttime来比较,time是行情k线位置的时间,currenttime是计算机当前时间,这两个时间对比,可以达到类似的效果。
是,使用application对象的playsound方法,播放一首歌,可以通过一个变量来控制是否已经在播放,如果在播放就不播,如果没有就开始播,然后设置变量的值,如果有行情了,就是用application对象的stopplay方法停止播放,并且设置变量的值。
好人做到底,直接发现诚代码了。
private isPlay
Sub TEST()
Set Report1=MarketData.GetReportData("IF00","ZJ")
StockTime=Report1.Date
TimeSpace=DateDiff("s",Cdate(Now),StockTime)
if abs(TimeSpace)>30 then
sSong=document.GetPrivateProfileString("Gen", "Alert","", "C:\ChanOrder.ini")
if sSong<>"" and isPlay=0 then
call application.PlaySoundFile(sSong)
isPlay=1
Application.MsgOut "请注意,行情数据已经超过30秒没有更新了!"
Exit Sub
end if
else
call application.StopPlay()
isPlay=0
end if
End Sub