This function calculates the difference between two times

xiaoxiao2021-03-06  84

'*****************************

'|| Function Timediff (Sbegin, Send)

'|| This function calculates the difference between two times, you can use it directly without changes

'|| Author: machinecat 2001/10/26

'*****************************

'*****************************

'Note: First, you need to judge the size of SBEGIN and SEND input.

'You can get the difference between the two through the DATADIFF function, do not need complex time conversion

'*****************************

Function Timediff (Sbegin, Send)

DIM IHOURB, IMINUTEB, ISECONDB, IMINISECONDB

DIM IHOURE, IMINUTEE, ISECONDE, IMINISECONDE

DIM DTIMEB, DTIMEE, DTIMEDIFF

DIM IHOUR, IMINUTE, ISECOND, IMINISECOND

IHOURB = ClNG (Left (Sbegin, 2))

iMinuteb = clng (MID (Sbegin, 4, 2))

ISECondb = ClNG (MID (Sbegin, 7, 2))

Imisecondb = ClNG (MID (Sbegin, 10, 4))

Ihai = clng (Left (seund, 2))

iMinutee = CLNG (MID (Send, 4, 2))

Iseconde = CLNG (MID (Send, 7, 2))

Imiseconde = ClNG (MID (Send, 10, 4))

DTIMEB = IHOURB * 3600 IMINUTEB * 60 ISECONDB IMINISECONDB / 1000

DTIMEE = IHOURE * 3600 IMINUTEE * 60 ISECONDE IMINISECONDE / 1000

DTIMEDIFF = DTIMEE - DTIMEB

IHOUR = INT (DTIMEDIFF / 3600)

DTIMEDIFF = DTIMEDIFF - IHOUR * 3600

iMinute = int (DTIMEDIFF / 60)

DTIMEDIFF = DTIMEDIFF - IMINUTE * 60

Isecond = int (DTIMEDIFF)

DTIMEDIFF = DTIMEDIFF - INT (DTIMEDIFF)

Iminisecond = DTIMEDIFF

Timediff = IHOUR & "Hours" & iMinute & "Mini Isecond & FormatNumber (IMINISECOND, 3) &" Second "

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-96200.html

New Post(0)