Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2017, 10:05 AM
sktamrkar sktamrkar is offline
Member
 
Join Date: Oct 2013
Posts: 66
Default Enable button control after getting a system time

Hi experts,
I need ur help on following problem:-
I have two form. Ist form have some label controls, a timer and a button control. When form1 execute and time left 2 minutes to take 11:00:00 of system time, then time left display on one label control and when system time reach at 11:00:00, button control enable. Button click event trigger to form2.


Thnx in adv.
Sandeep kumar
Reply With Quote
  #2  
Old 01-10-2017, 09:32 AM
sktamrkar sktamrkar is offline
Member
 
Join Date: Oct 2013
Posts: 66
Default Trouble while executing code

I have code for my problem but while running code something goes wrong. I am not understanding where i am wrong. I store time in ms access database and compare it with system current time and do the necessary operation. I submit my project. Plz give me solution.


Thnx
Sandeep
Attached Files
File Type: zip Time.zip (19.1 KB, 1 views)
Reply With Quote
  #3  
Old 01-12-2017, 09:05 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 162
Default

Quote:
Originally Posted by sktamrkar View Post
Hi experts,
I need ur help on following problem:-
I have two form. Ist form have some label controls, a timer and a button control. When form1 execute and time left 2 minutes to take 11:00:00 of system time, then time left display on one label control and when system time reach at 11:00:00, button control enable. Button click event trigger to form2.


Thnx in adv.
Sandeep kumar
Sorry, but it is very difficult to understand your statement.

Please try to better explain what

"and time left 2 minutes to take 11:00:00 of system time"

means.

does 11:00:00 mean 11 hours, 11 minutes, 11 O'clock??? Are you attempting to "count down" a period of time?
Reply With Quote
  #4  
Old 01-13-2017, 02:22 AM
sktamrkar sktamrkar is offline
Member
 
Join Date: Oct 2013
Posts: 66
Default Explain

Rojam sir, i explain my problem:
1. I have 2 forms, first form have 2 label controls, a button controls, a TADOTable control link with access database table.
2. The database table store student roll no, password and time for exam start.
3. I code to compare database table time with system time using "time" function. The difference between both time display on one label control and when both are equal the button visible.
I have attached my project in my second post.
i.e. exam time start : 9:15 AM, system time : 9:10 AM. label displays 5 minutes left in count down timer.

Thnx
Sandeep kumar

Last edited by sktamrkar; 01-13-2017 at 03:33 AM.
Reply With Quote
  #5  
Old 01-13-2017, 03:23 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 162
Default

Quote:
when both are equal the button visible
You do realize that both times would probably NEVER be EQUAL. A TTime variable keeps the time down to the millisecond, so if the application doesn't request the time at exactly the correct millisecond, the two times will not be equal. You need to compare the current time >= time in the database.
Reply With Quote
  #6  
Old 01-13-2017, 04:08 PM
sktamrkar sktamrkar is offline
Member
 
Join Date: Oct 2013
Posts: 66
Default

Sir rojam, plz execute once my project. I am wondering that executing the app then label shows something rediculous i.e. my database has exam time 9:15 am and the system time 9:10 am. Now the difference on label shows as 12:04:35. Again execute app then label shows 12:04:30 and so on. I want to show only 00:04:26 and so on.


Thnx
Sandeep
Reply With Quote
  #7  
Old 01-13-2017, 04:18 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 162
Default

That is because you are just subtracting one time from another and displaying the result as a TTime variable itself.
Try something like
Code:
uses ..., DateUtils;
 
...
 
var
  m: Int64;
  TimeBetween: String;
begin
  m := MinutesBetween(EndTime,StartTime);
  TimeBetween := Format('%2.2d:%2.2d',[m div 60,m mod 60]);
end;
replace Endtime and StartTime with the actual values

or you may want to look at MinuteSpan rather than MinutesBetween
http://docwiki.embarcadero.com/Libra...ils.MinuteSpan

Last edited by rojam; 01-13-2017 at 04:28 PM.
Reply With Quote
  #8  
Old 01-13-2017, 04:22 PM
sktamrkar sktamrkar is offline
Member
 
Join Date: Oct 2013
Posts: 66
Default

Thnx sir rojam i will try the code and post result soon.


Sandeep
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 06:23 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.