DateAndTime.Timer 屬性
傳回 Double 值,表示午夜之後所經過的秒數。
命名空間: Microsoft.VisualBasic
組件: Microsoft.VisualBasic (在 microsoft.visualbasic.dll 中)
語法
'宣告
Public Shared ReadOnly Property Timer As Double
'用途
Dim value As Double
value = DateAndTime.Timer
public static double Timer { get; }
public:
static property double Timer {
double get ();
}
/** @property */
public static double get_Timer ()
public static function get Timer () : double
屬性值
傳回 Double 值,表示午夜之後所經過的秒數。
備註
如需詳細資訊,請參閱 Visual Basic 的主題 Timer 屬性。
Timer 屬性會傳回前一天午夜之後所經過的秒數和毫秒數。秒數是傳回值的整數部分,而毫秒數則是小數部分。
範例
此範例使用 Timer 屬性來暫停應用程式。它可以在暫停期間執行其他處理。
Public Sub waitFiveSeconds()
If TimeOfDay >= #11:59:55 PM# Then
MsgBox("The current time is within 5 seconds of midnight" & _
vbCrLf & "The timer returns to 0.0 at midnight")
Return
End If
Dim start, finish, totalTime As Double
If (MsgBox("Press Yes to pause for 5 seconds", MsgBoxStyle.YesNo)) _
= MsgBoxResult.Yes Then
start = Microsoft.VisualBasic.DateAndTime.Timer
' Set end time for 5-second duration.
finish = start + 5.0
Do While Microsoft.VisualBasic.DateAndTime.Timer < finish
' Do other processing while waiting for 5 seconds to elapse.
Loop
totalTime = Microsoft.VisualBasic.DateAndTime.Timer - start
MsgBox("Paused for " & totalTime & " seconds")
End If
End Sub
請注意,您必須以 Microsoft.VisualBasic 命名空間限定 Timer 屬性,因為 Timer 也是 System.Threading、System.Timers 和 System.Windows.Forms 命名空間中定義的類別。
平台
Windows 98、 Windows 2000 SP4、 Windows CE、 Windows Millennium Edition、 Windows Mobile for Pocket PC、 Windows Mobile for Smartphone、 Windows Server 2003、 Windows XP Media Center Edition、 Windows XP Professional x64 Edition、 Windows XP SP2、 Windows XP Starter Edition
.NET Framework 並不支援各種平台的所有版本。如需支援平台版本的相關資訊,請參閱系統需求一節的內容。
版本資訊
.NET Framework
支援版本:2.0、1.1、1.0
.NET Compact Framework
支援版本:2.0、1.0
請參閱
參考
DateAndTime 類別
DateAndTime 成員
Microsoft.VisualBasic 命名空間
System
System.Windows.Forms
DateTime
ArgumentException
ArgumentOutOfRangeException