|
-
Oct 8th, 2003, 12:33 AM
#1
Thread Starter
Hyperactive Member
computing time
Hi I have a TextBox1, TextBox2 and TextBox3 control in my VB.NET Project.
TextBox1.Text = 9:30:33 AM
TextBox2.Text = 10:33:22 AM
I put this code into the Click Event of the Button1.
Dim TimeIn As DateTime
Dim TimeOut As DateTime
TimeIn = TextBox1.Text
TimeOut = TextBox2.Text
TextBox3.Text = Format((Int(TimeOut.Subtract(TimeIn).TotalMinutes) / 60), "hh:mm:ss")
But this code is doesn't work well!
The TextBox3 display "hh:mm:ss" and not "1:03:11"
What code should I write?
-
Oct 8th, 2003, 12:46 AM
#2
Addicted Member
Well, here's what worked for me. Instead of:
VB Code:
TextBox3.Text = Format((Int(TimeOut.Subtract(TimeIn).TotalMinutes) / 60), "hh:mm:ss"),
Try:
VB Code:
TextBox3.Text = TimeOut.Subtract(TimeIn).ToString
That will show the time difference in hh:mm:ss format, which is 01:02:49.
Last edited by The Phoenix; Oct 8th, 2003 at 01:01 AM.
Take my love
Take my land
Take me where I cannot stand
I don't care, I'm still free
You can't take the sky from me...
-
Oct 8th, 2003, 01:05 AM
#3
Thread Starter
Hyperactive Member
I've to write the code;
TextBox3.Text = Format((Int(TimeOut.Subtract(TimeIn).TotalMinutes) / 60), "hh:mm:ss")
But the TextBox3 display "hh:mm:ss" and not the time used!
-
Oct 8th, 2003, 05:39 PM
#4
Addicted Member
Well, you can't format that number like that. The number that results from:
VB Code:
TextBox3.Text = Format((Int(TimeOut.Subtract(TimeIn).TotalMinutes) / 60)
is: 1.03333333333333
That can't be formatted into "hh:mm:ss", so I think that is the problem. You HAVE to use the code you wrote? Cause if so, I don't see how it can work that way. What exactly do you want Textbox3 to display? "1.0333..." or "01:02:49"?
Take my love
Take my land
Take me where I cannot stand
I don't care, I'm still free
You can't take the sky from me...
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
|