 |
 |

04-24-2003, 02:01 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 10
|
|
Beginner help with timers. School program...
|
Can someone help me now adding timers to a program for school?
It's about a sunscreen.
|
|

04-24-2003, 02:08 AM
|
 |
Junior Contributor
|
|
Join Date: Feb 2003
Location: Philippines
Posts: 336
|
|
We are very much willing to help here. You just need to be more specific. in what part are you having problems with?
Pls be informed also for our posting guidelines, we are also not allowed to do all the coding for homework assignments. 
|
|

04-24-2003, 02:13 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 10
|
|
|
I have the whole program done, accept for the timers
the suncreen has to change to open or half open when the wind changes. but because it can be just a little wind, it has to be delayed with about 10 seconds.
same with the light. but then it has to be delayed for 30 seconds or so
can i mail u the sourcecode, so u can look at it?
I would be so thankful!!!!
|
|

04-24-2003, 02:20 AM
|
 |
Junior Contributor
|
|
Join Date: Feb 2003
Location: Philippines
Posts: 336
|
|
Sure! but I suggest to post your code in here. If its too long, you can attach it as a zipped file. I am suggesting this because there are also a lot members here that have more brains than I do (you know, the experts, gurus, etc..)  . They can suggest much better ways in making vb programs work efficiently.
|
|

04-24-2003, 02:36 AM
|
 |
Junior Contributor
|
|
Join Date: Oct 2002
Location: New Zealand
Posts: 217
|
|
Well, you could use This method:
Code:
Sub Delay(Amount as Single) 'This sub pauses for a given time
Dim StartTime as Single
Dim CurrentTime as single
StartTime = timer
Do
CurrentTime = timer
Doevents
Loop while CurrentTime < StartTime + amount
End sub
Now, when you want to delay, you call the sub.
For example:
Code:
....'Some code here
Delay(30.0) 'delay 30 secs..
....'More code here
Hope that helps,
Chris
|
|

04-24-2003, 02:39 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 10
|
|
|
It's to long to post it here, so I zipped it..
The form is in Dutch, but I'll tel u what everything means.
Zonnewering and zonnescherm = sunscreen (a screen against the sun, I don't know the English word for it)
Verlichting = light
dicht = closed
I put 2 timers in the form, 1 for the light, and 1 for the wind...
Do I need to use these or can I use what vb_recruit said?
|
|

04-24-2003, 02:41 AM
|
 |
Junior Contributor
|
|
Join Date: Oct 2002
Location: New Zealand
Posts: 217
|
|
|
You could just Use my method, or you could use Timers.
You decide.
Chris
|
|

04-24-2003, 02:43 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 10
|
|
|
but could u read my sourcecode and tell me where to put the source u mentioned?
|
|

04-24-2003, 02:45 AM
|
 |
Junior Contributor
|
|
Join Date: Oct 2002
Location: New Zealand
Posts: 217
|
|
|
Uh, you just place that sub down - and then,
you just place the delay(30.0) bit (for 30 secs) wherever you want it to pause.
Chris
|
|

04-24-2003, 02:48 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 10
|
|
|
ok, i'll try it right away...
thanx!
|
|

04-24-2003, 02:57 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 10
|
|
|
I can't get it to work...
if I put it between what needs 2 be delayed, then the screen won't close
help?
|
|

04-24-2003, 03:07 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 10
|
|
|
I got it 2 work, partualy...
If WindM = "5" And Schakelaar = "Automatisch" And VerlichtingM = "6" And Regen.Caption = "Droog" Then Delay (10#) And Scherm.Caption = "HALF OPEN"
now scherm.caption goes to "HALF OPEN" right away, but the picture I bound 2 scherm.caption delays for 10 seconds...
i don't get it...
|
Last edited by KreeZiE; 04-24-2003 at 03:17 AM.
|

04-24-2003, 03:21 AM
|
 |
Junior Contributor
|
|
Join Date: Feb 2003
Location: Philippines
Posts: 336
|
|
|
KreeZie, you dont have to post your code! You have already posted an attachment. Posting very long codes such as this doesnt help because we had a hard time reading it.
Have you copied the code vb_recruit gave you? You can copy and paste it at the bottom of you code and you can call it anywhere, as he said. Now, just call the procedure to the part where the "suncreen has to change to open or half open when the wind changes" in your program.
|
|

04-24-2003, 03:25 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 10
|
|
|
sorry for posting the code, I already deleted it...
the delay sub is on the bottom now, and it's working, not all the way I wanted it, but I think it's good enough...
I just don't get it, the text changes right away, and the picture i bound to it delays for 10 seconds...
why doesn't the text delay?
|
|

04-24-2003, 03:30 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 10
|
|
|
o no, i forgot something...
If the value is changed back, then the delay has to end...
an example: the screen goes out with a value of 6 or above.
but if the sun is shining for only 5 seconds and goes behind the clouds again, then the screen musn't go open.
|
|

04-24-2003, 03:31 AM
|
 |
Junior Contributor
|
|
Join Date: Feb 2003
Location: Philippines
Posts: 336
|
|
Code:
If WindM = "5" And Schakelaar = "Automatisch" And VerlichtingM = "6" And Regen.Caption = "Droog" Then Delay (10#) And Scherm.Caption = "HALF OPEN"
I quote the above code from your previous post. Is this code you are using now which according to you works partialy? Try removing the "And" after Delay(10#).
I cant test your code because I cant get it to work. 
|
|

04-24-2003, 03:34 AM
|
|
Newcomer
|
|
Join Date: Apr 2003
Posts: 10
|
|
|
if i delete the and after it, it gives an error..
I'll zip the program again, with all the other files to...
The exe file is included 2, so u know what i mean..
|
|

04-24-2003, 03:56 AM
|
 |
Junior Contributor
|
|
Join Date: Feb 2003
Location: Philippines
Posts: 336
|
|
Do it this way so that you will not get an error:
Code:
If WindM = "5" And Schakelaar = "Automatisch" And VerlichtingM = "6" And Regen.Caption = "Droog" Then
Delay (10#)
Scherm.Caption = "HALF OPEN" 'put this in another line
end if
Do the same to the rest of the codes.
|
|

04-24-2003, 04:45 PM
|
|
Junior Contributor
|
|
Join Date: Apr 2003
Location: San Diego, CA
Posts: 301
|
|
|
From what I get from reading the post and the code, it seems you want the program to control something like a shutter. The shutter activiation is triggered by a particular condition but actual implementation of the shutter action is to be delayed a specific period which can be interrupted before the activation actually begins.
If I surmise correctly, the Timer object would be the best option because the code detecting the condition for shutter activation can set the Timer Interval property for the desired delay and set the Enabled property to start the timer. Then, if the action to actually cause the shutter activation is triggered by the Timer reaching its specified interval. But if the condition changes and the activation should be cancelled, the Timer Enabled property can stop the Timer function before the shutter activation occurs.
I'm also guessing this is not the full program since everything since there is no code that is called except the Form_Load() event unless a control is clicked. If you want an automated control process, you need something to periodically trigger the various routines to monitor the conditions and decide what if any action needs to be started.
This might be a Do ... Loop structure in the Form_Activate() Event procedure which cyclically interrogates each pertinent routine while the program is running.
This D0 ... Loop structure could be triggered by a timer also so that it does its thing maybe ten times per second which is probably more than adequate for the kind of responses you seem to needf rom the program and the extenal hardware.
I hope this is of some help and not just useless rambling.
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|