|
-
Oct 15th, 2002, 10:03 AM
#1
Thread Starter
Junior Member
timing operations
So here I am trying to time a form's load and I'm not quite sure how to go about it.
In vb6 I'd do this:
dim start as double
dim lapsed as double
start = timer
lapsed = timer - start
and it actually worked for a console application in .net but not when I've tried it in a form. I've looked at the Timer property in MSDN and it doesn't specify what context the example its used in.
Any ideas?
-
Oct 16th, 2002, 03:55 AM
#2
Hyperactive Member
Try this
VB Code:
dim intStartTime as int32
dim intEndTime as int32
dim dblElapseTime as Double
dim strTime as String
intStartTime = System.Environment.TickCount
...
intEndTime = System.Environment.TickCount
dblElapseTime = (mintEndTime – mintStartTime) / 1000
strTime = dblElapseTime.Tostring & " Seconds"
-
Oct 16th, 2002, 08:33 AM
#3
Thread Starter
Junior Member
Thank you.
It works well.
-
Jan 28th, 2003, 01:04 AM
#4
New Member
I believe this is the method you are after:
VB Code:
Dim Start As Double = DateAndTime.Timer()
Code…
Dim Finish As Double = DateAndTime.Timer()
Me.Text = CStr(Start & " : " & Finish & " :: " & Finish - Start)
-
Jan 28th, 2003, 12:17 PM
#5
Hyperactive Member
Try this:
VB Code:
Dim TimeNow As New DateTime()
TimeNow = Now
Now.Subtract(TimeNow).TotalSeconds ' This is the elapsed time
There are also other properties:
.TotalDays
.TotalHours
.TotalMinutes
.TotalSeconds <---- the one I used in the above example
.TotalMilliseconds
They all convert the value of the time from ticks to their respective units. They have whole and fractional part.
Learn, this is the Keyword...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|