how do i calculate time ?

i has 3 text box


now the 1st text box show one time ie 12:00:59 am
and text 2 show 12:50:00 am

now i want my text 3  show the val after i minus the text1 and text2 val.

how do i put it in my command botton ?
JOHNHOAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RuslanMCommented:
Try this :

Private Sub Command1_Click()
Dim t1 as Date, t2 as Date, t3 as Date
t1=text1.text
t2=text2.text
if t1>t2 then
    t3=t1-t2
else
    t3=t2-t1
end if
text3.text=t3

Hope it works

0
crazymanCommented:
you should use datdiff for comparing dates.
text3=datediff("s",time1,time2)
gives differance in seconds
0
mcriderCommented:
Actually, try this code...

It will take the time in Text1 and Text2 and put elapsed time in text3.


Cheers!

The code:

Dim iLng As Long
Dim iHrs As Long
Dim iMin As Long
Dim iSec As Long
Dim lTime1 As String
Dim ltime2 As String
lTime1 = Format(CDate(Text1.Text), "hh:nn:ss")
ltime2 = Format(CDate(Text2.Text), "hh:nn:ss")
iLng = DateDiff("s", lTime1, ltime2)
iHrs = Fix(iLng / 3600)
iMin = Fix((iLng - (3600 * iHrs)) / 60)
iSec = Fix(iLng - (3600 * iHrs) - (iMin * 60))
Text3.Text = Format(iHrs, "00:") & Format(iMin, "00:") & Format(iSec, "00")
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mcriderCommented:
By the way, if you use my solution, please reject the current answer...

Cheers!
0
JOHNHOAuthor Commented:
thanks for trying to help me rustan m and crazy man.

nut mcrider code is more details.

thanks.

by the way mcrider, how do i send the point to you ?
0
JOHNHOAuthor Commented:
thanks for trying to help me rustan m and crazy man.

nut mcrider code is more details.

thanks.

by the way mcrider, how do i send the point to you ?
0
mcriderCommented:
Posting for the points...

Just accept this answer.

Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcriderCommented:
Thanks for the points!

Cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.