Function IsTradingTime(sMarket, iTime)
If sMarket="ZJ" then
IsTradingTime= iTime>91500+5 and iTime<113000-5 or iTime>130000+5 and iTime<151500-5
Elseif sMarket="DQ" or sMarket="ZQ" then
IsTradingTime= iTime>90000+5 and iTime<101500-5 or iTime>103000+5 and iTime<113000-5 or iTime>133000+5 and iTime<150000-5
Elseif sMarket="SQ" then
IsTradingTime= iTime>90000+5 and iTime<101500-5 or iTime>103000+5 and iTime<113000-5 or iTime>133000+5 and iTime<1410000-5 or iTime>142000+5 and iTime<150000-5
Else
IsTradingTime= 0
End if
End Function
调用语句
ddd=IsTradingTime("SQ", 151530)
Application.MsgOut(ddd)
返回值-1,预期值为0
在VBA中,的true跟false不是我们在C++中的 1和0,true在VBA中的值就是 -1 的,你的代码返回返回 -1说明你的代码存在逻辑错误。
建议你在IsTradingTime函数中多使用Application.MsgOut调试看看每个步骤及返回值查找问题