#1   Report Post  
Junior Member
 
Posts: 11
Default Windows startup

Dear Sir,

I wrote following codes to display windows Tickcount.
This userform work fine.
When commandbutton1 is pressed then Windows usage time displays.
I want to display it continuously. I mean when Userform loads then it should display running timer.

please help

Code:
Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Sub CommandButton1_Click()
Dim tickcount As Long
    tickcount = GetTickCount()
    Me.TextBox1.Value = tickcount
    Call tick2time
End Sub

Sub tick2time()
    Dim LNTICK As Long, LNHOUR As Integer, LNMIN As Integer
    LNTICK = Me.TextBox1.Value
    TNHOURS = Int(LNTICK / 3600000)
        If (TNHOURS  23) Then
            TNDAYS = Int(TNHOURS / 24)
            TNHOURS = TNHOURS Mod 24
        Else
            TNDAYS = 0
        End If

    LNTICK = LNTICK Mod 3600000
    TNMINUTES = Int(LNTICK / 60000)
    TNSECOND1 = (LNTICK Mod 60000) / 1000
    TNSECONDS = Int(TNSECOND1)
    Me.TextBox2.Value = Format(TNHOURS, "00") + ":" + Format(TNMINUTES, "00") + ":" + Format(TNSECONDS, "00")
    MsgBox ("Windows has started since  " + Me.TextBox2.Value)
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Windows startup

Private Sub CommandButton1_Click()
Dim tickcount As Long
Dim stopFlag As Boolean
Do Until stopFlag = True
tickcount = GetTickCount()
Me.TextBox1.Value = tickcount
Call tick2time
DoEvents()
Loop
End Sub

Because stopFlag never gets set to True, the loop runs 'forever'. The
DoEvents() allows the system to respond to other events and keeps this loop
from totally locking up the system/using 100% of the CPU time.
"tqm1" wrote:


Dear Sir,

I wrote following codes to display windows Tickcount.
This userform work fine.
When commandbutton1 is pressed then Windows usage time displays.
I want to display it continuously. I mean when Userform loads then it
should display running timer.

please help


Code:
--------------------

Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Sub CommandButton1_Click()
Dim tickcount As Long
tickcount = GetTickCount()
Me.TextBox1.Value = tickcount
Call tick2time
End Sub

Sub tick2time()
Dim LNTICK As Long, LNHOUR As Integer, LNMIN As Integer
LNTICK = Me.TextBox1.Value
TNHOURS = Int(LNTICK / 3600000)
If (TNHOURS 23) Then
TNDAYS = Int(TNHOURS / 24)
TNHOURS = TNHOURS Mod 24
Else
TNDAYS = 0
End If

LNTICK = LNTICK Mod 3600000
TNMINUTES = Int(LNTICK / 60000)
TNSECOND1 = (LNTICK Mod 60000) / 1000
TNSECONDS = Int(TNSECOND1)
Me.TextBox2.Value = Format(TNHOURS, "00") + ":" + Format(TNMINUTES, "00") + ":" + Format(TNSECONDS, "00")
MsgBox ("Windows has started since " + Me.TextBox2.Value)
End Sub

--------------------




--
tqm1

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Windows startup

By the way, I'd get rid of tha MsgBox statement in sub tick2time - you're
going to get a message box EVERY time it goes through the loop I created and
you're going to end up spending eternity clearing them - might want to just
add another text box to the form to display the information being shown in
the MsgBox now.

"tqm1" wrote:


Dear Sir,

I wrote following codes to display windows Tickcount.
This userform work fine.
When commandbutton1 is pressed then Windows usage time displays.
I want to display it continuously. I mean when Userform loads then it
should display running timer.

please help


Code:
--------------------

Private Declare Function GetTickCount Lib "kernel32" () As Long

Private Sub CommandButton1_Click()
Dim tickcount As Long
tickcount = GetTickCount()
Me.TextBox1.Value = tickcount
Call tick2time
End Sub

Sub tick2time()
Dim LNTICK As Long, LNHOUR As Integer, LNMIN As Integer
LNTICK = Me.TextBox1.Value
TNHOURS = Int(LNTICK / 3600000)
If (TNHOURS 23) Then
TNDAYS = Int(TNHOURS / 24)
TNHOURS = TNHOURS Mod 24
Else
TNDAYS = 0
End If

LNTICK = LNTICK Mod 3600000
TNMINUTES = Int(LNTICK / 60000)
TNSECOND1 = (LNTICK Mod 60000) / 1000
TNSECONDS = Int(TNSECOND1)
Me.TextBox2.Value = Format(TNHOURS, "00") + ":" + Format(TNMINUTES, "00") + ":" + Format(TNSECONDS, "00")
MsgBox ("Windows has started since " + Me.TextBox2.Value)
End Sub

--------------------




--
tqm1

  #4   Report Post  
Junior Member
 
Posts: 11
Default

Quote:
Originally Posted by JLatham View Post
By the way, I'd get rid of tha MsgBox statement in sub tick2time - you're
going to get a message box EVERY time it goes through the loop I created and
you're going to end up spending eternity clearing them - might want to just
add another text box to the form to display the information being shown in
the MsgBox now.
Remove this lin from codes

MsgBox ("Windows has started since " + Me.TextBox2.Value)
  #5   Report Post  
Junior Member
 
Posts: 11
Default

Quote:
Originally Posted by JLatham View Post
Private Sub CommandButton1_Click()
Dim tickcount As Long
Dim stopFlag As Boolean
Do Until stopFlag = True
tickcount = GetTickCount()
Me.TextBox1.Value = tickcount
Call tick2time
DoEvents()
Loop
End Sub

Because stopFlag never gets set to True, the loop runs 'forever'. The
DoEvents() allows the system to respond to other events and keeps this loop
from totally locking up the system/using 100% of the CPU time.
My you could not understand my problem, please read following paragrph again

"When commandbutton1 is pressed then Windows usage time displays.
I want to display it continuously. I mean when Userform loads then it should display running timer."

I want to remove commandbuton1, timer automatically must update values in both textboxes.

Please modify
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows 2000 vs Windows XP raypayette Excel Discussion (Misc queries) 4 July 23rd 06 12:53 PM
Page breaks are different in Windows 2000 and Windows XP Bill Allen Excel Discussion (Misc queries) 1 November 23rd 05 04:42 PM
disable eurovalue windows at excel startup grooviechez Excel Discussion (Misc queries) 4 February 8th 05 01:47 PM
Windows Installer (Visio) on Excel Startup Olly Setting up and Configuration of Excel 0 December 9th 04 04:35 AM
Windows ME and Windows XP Function of key F2 is different jimnav Excel Worksheet Functions 2 November 21st 04 07:05 PM


All times are GMT +1. The time now is 05:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"