Problem with variables?

I have two control buttons. I have both of them entering the system date into two seperate text boxes when clicked. I need the second control button to enter the system date (which it does) and use the variables left over from the first control button to subtract them from the variables left over from the second button.

This currently is not working. I wanted to test my code so I switched the variables around so the second button was subtracting one variable in the Control code from the other variable in that same Control button code and displaying it in a text box. This worked fine. This leads me to believe that it is a variable problem. Since VB gets rid of the variable contents once used the variable must be getting dumped. I tried using Static and changing it to Public to see if this would work, but still nothing. Here is the code for the two control buttons: - Any ideas?

Public Sub cmdIn_Click()

clkTimein = Format$(Time, "hh:mm")
txtIn.Text = clkTimein
hrIn = Left(clkTimein, 2)
minIn = Right(clkTimein, 2)
hrInone = Val(hrIn)
minInone = Val(minIn)

End Sub

Public Sub cmdOut_Click()

clkTimeout = Format$(Time, "hh:mm")
txtOut.Text = clkTimeout
hrOut = Left(clkTimeout, 2)
minOut = Right(clkTimeout, 2)
hrOutone = Val(hrOut)
minOutone = Val(minOut)
numTothr = hrOutone + minOutone
numTotmin = minOutone + minInone
strTothr = Str(numTothr)
strTotmin = Str(numTotmin)
txtTothr.Text = strTothr
txtTotmin.Text = strTotmin

End Sub
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.

Use text box as variable.

Your code cleeared looks essentially like this:

Public Sub cmdIn_Click()
txtIn = Format$(Time, "hh:mm")
End Sub

Public Sub cmdOut_Click()

txtTothr.Text = Left(Format$(Time, "hh:mm"), 2) + Right(Format$(Time, "hh:mm"), 2)
txtTotmin.Text = Right(Format$(Time, "hh:mm"), 2)  + Right(txtIn, 2)

End Sub
ammo325Author Commented:
Thank you for the response. That didn't really fix it totally, unfortunately the boxes are still showing the incorrect value.
What exactly you want do?
If time in textIn is "12:00"
and time now is "12:12"
what do you want to see in txtOut?
Ultimate Tool Kit for Technology Solution Provider

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 now.

ammo325Author Commented:
I would like to see 0012

Its a program that has a time in and a time out. So the time out will always need time in subtracted from it to show the duration that has passed.
Then check DateDiff function.

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
Bistrica is right; what you want to do is trivial (not to minimise the difficulty you've had with it - I simply mean you should use DateDiff and achieve what you want in simply one line of code!).
ammo325Author Commented:
Thank you. I will try that. I have a nice tutorial book on VB6, doesn't mention DateDiff in it that I know of. Not in the index anyway.
Here, try this Web page for a tutorial on various time and date-handling functions in VB6 (including DateDiff):

(Careful - it's a long URL and the lines may wrap).
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
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

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.