Have I missed sonething here? MOD should return an integer.
Why do I get "15:30.33333333333334:20.0000000000000031" returned here ?
#COMPILE EXE
FUNCTION strhours(hournum AS DOUBLE) AS STRING
'convert hours to "hh:mm:ss"
FUNCTION = TRIM$(STR$(INT(hournum))) & ":" _
& TRIM$(STR$((hournum * 60) MOD 60)) & ":" _
& TRIM$(STR$((hournum * 3600) MOD 60))
END FUNCTION
FUNCTION numhours( strTime AS STRING) AS DOUBLE
'convert "hh:mm:ss" to hours
FUNCTION = VAL(PARSE$(strTime,":",1)) _
+ VAL(PARSE$(strTime,":",2))/60 _
+ VAL(PARSE$(strTime,":",3))/3600
END FUNCTION
FUNCTION PBMAIN
LOCAL strTemp AS STRING
strtemp = "15:30:20"
MSGBOX strhours(numhours(strTemp))
END FUNCTION
------------------
Check out my free software at http://www.lexacorp.com.pg(all written in PB/DLL)
[This message has been edited by Stuart McLachlan (edited June 16, 2001).]
Why do I get "15:30.33333333333334:20.0000000000000031" returned here ?
#COMPILE EXE
FUNCTION strhours(hournum AS DOUBLE) AS STRING
'convert hours to "hh:mm:ss"
FUNCTION = TRIM$(STR$(INT(hournum))) & ":" _
& TRIM$(STR$((hournum * 60) MOD 60)) & ":" _
& TRIM$(STR$((hournum * 3600) MOD 60))
END FUNCTION
FUNCTION numhours( strTime AS STRING) AS DOUBLE
'convert "hh:mm:ss" to hours
FUNCTION = VAL(PARSE$(strTime,":",1)) _
+ VAL(PARSE$(strTime,":",2))/60 _
+ VAL(PARSE$(strTime,":",3))/3600
END FUNCTION
FUNCTION PBMAIN
LOCAL strTemp AS STRING
strtemp = "15:30:20"
MSGBOX strhours(numhours(strTemp))
END FUNCTION
------------------
Check out my free software at http://www.lexacorp.com.pg(all written in PB/DLL)
[This message has been edited by Stuart McLachlan (edited June 16, 2001).]
Comment