找回密码
 加入
搜索
查看: 19065|回复: 5

[AU3基础] [已解决]如何将 秒 转换为 :时 分 秒 ? 帮帮忙!

[复制链接]
发表于 2013-9-2 16:54:57 | 显示全部楼层 |阅读模式
本帖最后由 laomeng 于 2013-9-3 09:32 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
 
Global $time = 70
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("提示", 350, 172, 193, 125)
$Label1 = GUICtrlCreateLabel("", 56, 52, 235, 48)
GUICtrlSetColor(-1,0x1B9327)
GUICtrlSetFont(-1, 18, 400, 0, "楷体_GB2312")
$Button1 = GUICtrlCreateButton("确定(&Y)", 53, 128, 73, 25, 0)
$Button2 = GUICtrlCreateButton("退出(&X)", 210, 128, 73, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
AdlibRegister ("_timer", 1000)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE, $Button2
                        Exit
                Case $Button1
                        ExitLoop
        EndSwitch
        If $time <= 0 Then ExitLoop
WEnd

Exit
 
Func _timer()
        $time -= 1
                If $time < 60 Then GUICtrlSetColor($Label1,0xDD2113)
        GUICtrlSetData($Label1,"距离下次宝藏开启还剩" & $time & "秒")
        If $time <= 0 Then AdlibUnRegister()
EndFunc   ;==>_timer
 
例如166秒  如何 将 秒 显示为 X小时 X分 X 秒
发表于 2013-9-2 18:44:55 | 显示全部楼层
回复 1# laomeng
Local $iSec = 3666
MsgBox(0, '', _convert_sec($iSec))
Func _convert_sec($iSec)
        Local $iHour, $iMin
        $iHour = Int($iSec/3600)
        $iMin = Int(($iSec-$iHour*3600)/60)
        $iSec = $iSec - $iHour*3600 - $iMin*60
        Switch $iHour
                Case 0
                        If $iMin <> 0 Then Return $iMin & '分' & $iSec & '秒'
                        Return $iSec & '秒'
                Case Else
                        Return $iHour & '小时' & $iMin & '分' & $iSec & '秒'
        EndSwitch
EndFunc
发表于 2013-9-2 23:24:06 | 显示全部楼层
回复 2# user3000


   其中秒数
$iSec = mod($iSec,60)

评分

参与人数 1金钱 +20 收起 理由
user3000 + 20 ++谢谢指正

查看全部评分

发表于 2013-9-2 23:39:59 | 显示全部楼层
本帖最后由 user3000 于 2013-9-2 23:55 编辑

回复 3# xlj310

再三思考了下,这样确实简洁了代码及运算过程!
我竟然没想到这原理: 原数除以60秒(1分钟),余数即是要转化的'秒'.
 楼主| 发表于 2013-9-3 09:30:39 | 显示全部楼层
回复 4# user3000


    非常感谢 !
 楼主| 发表于 2013-9-3 09:31:03 | 显示全部楼层
谢谢  两位的回答! 已解决了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-28 21:21 , Processed in 0.080592 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表