Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Problem with variables?

Posted on 2003-03-29
10
Medium Priority
?
244 Views
Last Modified: 2010-04-17
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
0
Comment
Question by:ammo325
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 4

Expert Comment

by:bistrica
ID: 8229786
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
0
 

Author Comment

by:ammo325
ID: 8229864
Thank you for the response. That didn't really fix it totally, unfortunately the boxes are still showing the incorrect value.
0
 
LVL 4

Expert Comment

by:bistrica
ID: 8229951
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?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ammo325
ID: 8229956
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.
0
 
LVL 4

Accepted Solution

by:
bistrica earned 200 total points
ID: 8231125
Then check DateDiff function.
0
 
LVL 4

Expert Comment

by:davidmwilliams
ID: 8233287
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!).
0
 

Author Comment

by:ammo325
ID: 8233360
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.
0
 
LVL 4

Assisted Solution

by:davidmwilliams
davidmwilliams earned 100 total points
ID: 8233529
Here, try this Web page for a tutorial on various time and date-handling functions in VB6 (including DateDiff):

http://www.informit.com/isapi/product_id~%7B3EBD1237-3C91-4CF3-A0BA-EB3976CD978B%7D/element_id~%7BDFB7DBFE-2D09-4390-AE5B-25830B89A558%7D/st~%7B8B377B75-8B63-4AEA-BEA1-4917BA2DDED0%7D/content/articlex.asp

(Careful - it's a long URL and the lines may wrap).
0
 

Expert Comment

by:CleanupPing
ID: 9446681
ammo325:
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 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Six Sigma Control Plans
Loops Section Overview

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question