Tick Counter

Introduction

The Win32 library provides a special function used to count a specific number of lapses that have occurred since you started your computer. This information or counter is available through the GetTickCount() function. Its syntax is:

DWORD GetTickCount(VOID);

This function takes no argument. If it succeeds in performing its operation, which it usually does, it provides the number of milliseconds that have elapsed since you started your computer. Just like the timer control, what you do with the result of this function is up to you and it can be used in various circumstances. For example, computer games and simulations make great use of this function.

After retrieving the value that this function provides, you can display it in a text-based control.

 

  1. Start Microsoft Visual Basic and create a Standard EXE application
  2. Save the application in a new folder named Computer Time
  3. Save the form as frmMain and save the project as TickCounter
  4. Design the form as follows
     
    Control Properties
    Form Name: frmMain
    Border Style: 3 - FixedDialog
    Caption: Tick Counter
    Label Name: lblAppTime
    Label Name: txtCompTime
    Timer Interval: 20
  5. Double-click an unoccupied area on the form to launch its OnLoad event
  6. Also, initiate the OnTimer event of the Timer control
  7. Implement the file as follows:
     
    Private Declare Function Win32GetTickCounter Lib "Kernel32" Alias "GetTickCount" () As Long
    Private CompTime As Long
    Private Sub Form_Load()
        CompTime = Win32GetTickCounter
    End Sub
    
    Private Sub Timer1_Timer()
        Dim TickValue  As Long
        Dim Difference As Long
        
        TickValue = Win32GetTickCounter
        Difference = TickValue - CompTime
        
        Dim ComputerHours As Long
        Dim ComputerMinutes As Long
        Dim ComputerSeconds As Long
        Dim ApplicationHours, ApplicationMinutes, ApplicationSeconds As Long
    
        ComputerHours = (TickValue \ 3596400) Mod 24
        ComputerMinutes = (TickValue \ 59940) Mod 60
        ComputerSeconds = (TickValue \ 999) Mod 60
        ApplicationHours = (Difference \ 3596400) Mod 24
        ApplicationMinutes = (Difference \ 59940) Mod 60
        ApplicationSeconds = (Difference \ 999) Mod 60
        
        lblAppTime.Caption = "This application has been ON for " & _
                         CStr(ApplicationHours) & " hours, " & _
                         CStr(ApplicationMinutes) & " minutes, and " & _
                         CStr(ApplicationSeconds) & " seconds"
        
        lblCompTime.Caption = "This computer has been on for " & _
                         CStr(ComputerHours) & " hours, " & _
                         CStr(ComputerMinutes) & " mnutes, and " & _
                         CStr(ComputerSeconds) & " seconds"
    End Sub
  8. Test the application
 

Copyright 2004-2014 FunctionX, Inc.

两个鬼故事给宾馆起什么名字好钻石戒指起名大全笔记本功率傅起名字好和申焚琴煮鹤纤细的爱叶玄叶灵小说英文起名免费版起名笔画数查询狂怒扬字起名好不好直播cctv1非主流qq头像十四画属火的起名吉利字幻想三国志2攻略设计店铺起名姓潘的少女起名字查起名用字女孩宝宝起什么名字好奥比岛名字美术教育公司起名木命人的起名书起名tonightsgirlfriendhttpwww.renren.comfineprint品牌如何起名我们唱的歌根据中文名起英文名少年生前被连续抽血16次?多部门介入两大学生合买彩票中奖一人不认账让美丽中国“从细节出发”淀粉肠小王子日销售额涨超10倍高中生被打伤下体休学 邯郸通报单亲妈妈陷入热恋 14岁儿子报警何赛飞追着代拍打雅江山火三名扑火人员牺牲系谣言张家界的山上“长”满了韩国人?男孩8年未见母亲被告知被遗忘中国拥有亿元资产的家庭达13.3万户19岁小伙救下5人后溺亡 多方发声315晚会后胖东来又人满为患了张立群任西安交通大学校长“重生之我在北大当嫡校长”男子被猫抓伤后确诊“猫抓病”测试车高速逃费 小米:已补缴周杰伦一审败诉网易网友洛杉矶偶遇贾玲今日春分倪萍分享减重40斤方法七年后宇文玥被薅头发捞上岸许家印被限制高消费萧美琴窜访捷克 外交部回应联合利华开始重组专访95后高颜值猪保姆胖东来员工每周单休无小长假男子被流浪猫绊倒 投喂者赔24万小米汽车超级工厂正式揭幕黑马情侣提车了西双版纳热带植物园回应蜉蝣大爆发当地回应沈阳致3死车祸车主疑毒驾恒大被罚41.75亿到底怎么缴妈妈回应孩子在校撞护栏坠楼外国人感慨凌晨的中国很安全杨倩无缘巴黎奥运校方回应护栏损坏小学生课间坠楼房客欠租失踪 房东直发愁专家建议不必谈骨泥色变王树国卸任西安交大校长 师生送别手机成瘾是影响睡眠质量重要因素国产伟哥去年销售近13亿阿根廷将发行1万与2万面值的纸币兔狲“狲大娘”因病死亡遭遇山火的松茸之乡“开封王婆”爆火:促成四五十对奥巴马现身唐宁街 黑色着装引猜测考生莫言也上北大硕士复试名单了德国打算提及普京时仅用姓名天水麻辣烫把捣辣椒大爷累坏了

两个鬼故事 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化