2017-09-25 77 views

回答

2

功能IsTimeInRange()將返回True如果當前時間在所需的範圍內,否則False

Function IsTimeInRange() As Boolean 
    Return Now.DayOfWeek >= DayOfWeek.Monday AndAlso 
      Now.DayOfWeek <= DayOfWeek.Friday AndAlso 
      Now.Hour = 2 'Includes everything between "02:00:00.000 AM" and "02:59:59.999 AM" 
End Function 
+0

請問如何顯示1代表true或0代表false而不是布爾值? – qafro

+0

@qafro這真的很基礎和直接。只需使用一個簡單的「If」子句。有足夠的例子和教程。您是否參加了[Tour](https://stackoverflow.com/tour)並閱讀了[如何提問](https://stackoverflow.com/help/how-to-ask)以及[如何創建最小,完整且可驗證的示例](https://stackoverflow.com/help/mcve)? – MatSnow

+0

嘿,我得到Microsoft VBScript編譯錯誤:期望的聲明,任何想法的解決? – qafro

相關問題