Share via


Second 函式 (Visual Basic)

更新:2007 年 11 月

傳回介於 0 到 59 之間代表秒數的 Integer 值。

Public Function Second(ByVal TimeValue As DateTime) As Integer

參數

  • TimeValue
    必要項。您想要抽取秒數的 Date 值。

備註

您也可以呼叫 DatePart 和指定 DateInterval.Second 的 Interval 引數,以取得分鐘的秒數。

範例

下列範例會使用 Second 函式,從指定時間取得分鐘的秒數。在開發環境中會使用您的程式碼中地區設定,以簡短時間格式表示時間常值。

Dim thisTime As Date
Dim thisSecond As Integer
thisTime = #4:35:17 PM#
thisSecond = Second(thisTime)
' thisSecond now contains 17.

需求

命名空間:Microsoft.VisualBasic

**模組:**DateAndTime

**組件 (Assembly):**Visual Basic Runtime Library (在 Microsoft.VisualBasic.dll 中)

請參閱

參考

Day 函式 (Visual Basic)

Hour 函式 (Visual Basic)

Minute 函式

Now 屬性

TimeOfDay 屬性

DatePart 函式 (Visual Basic)

System

DateTime

ArgumentException

ArgumentOutOfRangeException