| | |
Text Timer
Thread Solved |
•
•
Join Date: Jan 2005
Posts: 3
Reputation:
Solved Threads: 0
Hi there, nice to meet you all.
I'm a beginner using visual basic only started to learn it about a months ago. I'm having serious trouble at the moment.
I need a program that as soon as it is opened it prints the time into 100ths or miliseconds of seconds, then run the proram and then print the time again just as it ends. (timer at the moment only shows the Time as HH:MM
S, i want it to show HH:MM
S:Miliseconds if possible)
For example i open the program and the display on the timer label is prined into Text1 then it runs my loop 10000 times then as soon as it finishes the loop i it to print the time on the timer into Text2.
The reason im doing this is i need to investigate speeds of processors in different machines and prove that the faster the processor the quicker it can complete this loop. Timing by had is just not accurate enough.
all i have so far is:
Private Sub Form_Load()
Text1.Caption = time
for x = 1 to 10000
Print "Frost"
next
Text2.Caption = time
Timer1.Interval = 1
Label1.Caption = ""
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub
1) I cant get the timer to go into hundreths or miliseconds.
2) I cant get the form to print the time on the timer into Text1 When it loads up
3) I cant get my loop to work, i have no idea why haha.
4) I cant get the form to print the time on the timer into Text2 When the loops finished.
Thanks so much for any help you can give, im just totally bamboozled as to how i'm supposed to do this.
I cant get it to work and i have been trying for 2 hours +
thanks again
Frost
P.S I have tried to enclose a screenshot of my program not quite the same as the one above but gives you the idea.
http://img81.exs.cx/img81/8927/vb6rg.jpg
I'm a beginner using visual basic only started to learn it about a months ago. I'm having serious trouble at the moment.
I need a program that as soon as it is opened it prints the time into 100ths or miliseconds of seconds, then run the proram and then print the time again just as it ends. (timer at the moment only shows the Time as HH:MM
S, i want it to show HH:MM
S:Miliseconds if possible)For example i open the program and the display on the timer label is prined into Text1 then it runs my loop 10000 times then as soon as it finishes the loop i it to print the time on the timer into Text2.
The reason im doing this is i need to investigate speeds of processors in different machines and prove that the faster the processor the quicker it can complete this loop. Timing by had is just not accurate enough.
all i have so far is:
Private Sub Form_Load()
Text1.Caption = time
for x = 1 to 10000
Print "Frost"
next
Text2.Caption = time
Timer1.Interval = 1
Label1.Caption = ""
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
End Sub
1) I cant get the timer to go into hundreths or miliseconds.
2) I cant get the form to print the time on the timer into Text1 When it loads up
3) I cant get my loop to work, i have no idea why haha.
4) I cant get the form to print the time on the timer into Text2 When the loops finished.
Thanks so much for any help you can give, im just totally bamboozled as to how i'm supposed to do this.
I cant get it to work and i have been trying for 2 hours +
thanks again
Frost
P.S I have tried to enclose a screenshot of my program not quite the same as the one above but gives you the idea.
http://img81.exs.cx/img81/8927/vb6rg.jpg
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub Form_Load() Text1.text = time for x = 1 to 10000 Print "Frost" next Text2.text = time Timer1.Interval = 1 Label1.Caption = "" End Sub Private Sub Timer1_Timer() Label1.Caption = Time End Sub
Alright, I've Got It:
You Need To Add A Plain Ole Standard Module (It's A Good Practice), inside of the module add this:
Module Code:
In your form load event, You'll need this code:
Form Load Code
And Lastly in your timer event:
Timer Event Code:
So Far, This works flawlessly for me. Let me know how it works for you.... if you need an additional help, let me know.
You Need To Add A Plain Ole Standard Module (It's A Good Practice), inside of the module add this:
Module Code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Public Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) Public Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long Public Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type
In your form load event, You'll need this code:
Form Load Code
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim GMTime As SYSTEMTIME Dim TheTime As String GetSystemTime GMTime Text1.Text = GMTime.wHour & ":" & GMTime.wMinute & ":" & GMTime.wSecond & "." & GMTime.wMilliseconds For x = 1 To 10000 Print "Frost" Next GetSystemTime GMTime Text2.Text = GMTime.wHour & ":" & GMTime.wMinute & ":" & GMTime.wSecond & "." & GMTime.wMilliseconds Timer1.Interval = 1 Label1.Caption = ""
And Lastly in your timer event:
Timer Event Code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim GMTime As SYSTEMTIME Dim TheTime As String GetSystemTime GMTime Label1.Caption = GMTime.wHour & ":" & GMTime.wMinute & ":" & GMTime.wSecond & "." & GMTime.wMilliseconds
So Far, This works flawlessly for me. Let me know how it works for you.... if you need an additional help, let me know.
•
•
Join Date: Jan 2005
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Comatose
Alright, I've Got It:
You Need To Add A Plain Ole Standard Module (It's A Good Practice), inside of the module add this:
Module Code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Public Declare Sub GetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) Public Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long Public Type SYSTEMTIME wYear As Integer wMonth As Integer wDayOfWeek As Integer wDay As Integer wHour As Integer wMinute As Integer wSecond As Integer wMilliseconds As Integer End Type
In your form load event, You'll need this code:
Form Load Code
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim GMTime As SYSTEMTIME Dim TheTime As String GetSystemTime GMTime Text1.Text = GMTime.wHour & ":" & GMTime.wMinute & ":" & GMTime.wSecond & "." & GMTime.wMilliseconds For x = 1 To 10000 Print "Frost" Next GetSystemTime GMTime Text2.Text = GMTime.wHour & ":" & GMTime.wMinute & ":" & GMTime.wSecond & "." & GMTime.wMilliseconds Timer1.Interval = 1 Label1.Caption = ""
And Lastly in your timer event:
Timer Event Code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim GMTime As SYSTEMTIME Dim TheTime As String GetSystemTime GMTime Label1.Caption = GMTime.wHour & ":" & GMTime.wMinute & ":" & GMTime.wSecond & "." & GMTime.wMilliseconds
So Far, This works flawlessly for me. Let me know how it works for you.... if you need an additional help, let me know.
wow!!! i cant thank you enough that is absolutely perfect!!! well done! Sorry its a little bit late, was away for a couple of days.
(a happy)Frost
•
•
Join Date: Dec 2004
Posts: 207
Reputation:
Solved Threads: 8
•
•
•
•
Originally Posted by Comatose
I didn't Know that. I appreciate that knowledge, since 1/18th isn't as reliable of a system to the millisecond. May I ask where you found this information?
1/18 second = 55 ms = the length of a Windows jiffy (timeslice). The hardware interrupts the Intel-type computer every 55 ms to switch processes in multiprocessing operating systems such as Windows.
All I/O is done at the beginning of each timeslice when Windows does its mousekeeping. Any I/O request by a program has to wait for the next jiffy.
![]() |
Similar Threads
- Seconds timer (C++)
- Countdown Timer (VB.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Please Help..
- Next Thread: similar of paintpicture
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






