Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Beginner help with timers. School program...


Reply
 
Thread Tools Display Modes
  #1  
Old 04-24-2003, 02:01 AM
KreeZiE KreeZiE is offline
Newcomer
 
Join Date: Apr 2003
Posts: 10
Default Beginner help with timers. School program...


Can someone help me now adding timers to a program for school?

It's about a sunscreen.
Reply With Quote
  #2  
Old 04-24-2003, 02:08 AM
starbitz's Avatar
starbitz starbitz is offline
Junior Contributor
 
Join Date: Feb 2003
Location: Philippines
Posts: 336
Default

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.
Reply With Quote
  #3  
Old 04-24-2003, 02:13 AM
KreeZiE KreeZiE is offline
Newcomer
 
Join Date: Apr 2003
Posts: 10
Default

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!!!!
Reply With Quote
  #4  
Old 04-24-2003, 02:20 AM
starbitz's Avatar
starbitz starbitz is offline
Junior Contributor
 
Join Date: Feb 2003
Location: Philippines
Posts: 336
Default

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.
Reply With Quote
  #5  
Old 04-24-2003, 02:36 AM
vb_recruit's Avatar
vb_recruit vb_recruit is offline
Junior Contributor
 
Join Date: Oct 2002
Location: New Zealand
Posts: 217
Default

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
Reply With Quote
  #6  
Old 04-24-2003, 02:39 AM
KreeZiE KreeZiE is offline
Newcomer
 
Join Date: Apr 2003
Posts: 10
Default

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?
Attached Files
File Type: zip Zonnewering.zip (3.6 KB, 10 views)
Reply With Quote
  #7  
Old 04-24-2003, 02:41 AM
vb_recruit's Avatar
vb_recruit vb_recruit is offline
Junior Contributor
 
Join Date: Oct 2002
Location: New Zealand
Posts: 217
Default

You could just Use my method, or you could use Timers.
You decide.

Chris
Reply With Quote
  #8  
Old 04-24-2003, 02:43 AM
KreeZiE KreeZiE is offline
Newcomer
 
Join Date: Apr 2003
Posts: 10
Default

but could u read my sourcecode and tell me where to put the source u mentioned?
Reply With Quote
  #9  
Old 04-24-2003, 02:45 AM
vb_recruit's Avatar
vb_recruit vb_recruit is offline
Junior Contributor
 
Join Date: Oct 2002
Location: New Zealand
Posts: 217
Default

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
Reply With Quote
  #10  
Old 04-24-2003, 02:48 AM
KreeZiE KreeZiE is offline
Newcomer
 
Join Date: Apr 2003
Posts: 10
Default

ok, i'll try it right away...

thanx!
Reply With Quote
  #11  
Old 04-24-2003, 02:57 AM
KreeZiE KreeZiE is offline
Newcomer
 
Join Date: Apr 2003
Posts: 10
Unhappy

I can't get it to work...

if I put it between what needs 2 be delayed, then the screen won't close

help?
Reply With Quote
  #12  
Old 04-24-2003, 03:07 AM
KreeZiE KreeZiE is offline
Newcomer
 
Join Date: Apr 2003
Posts: 10
Default

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.
Reply With Quote
  #13  
Old 04-24-2003, 03:21 AM
starbitz's Avatar
starbitz starbitz is offline
Junior Contributor
 
Join Date: Feb 2003
Location: Philippines
Posts: 336
Default

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.
Reply With Quote
  #14  
Old 04-24-2003, 03:25 AM
KreeZiE KreeZiE is offline
Newcomer
 
Join Date: Apr 2003
Posts: 10
Default

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?
Reply With Quote
  #15  
Old 04-24-2003, 03:30 AM
KreeZiE KreeZiE is offline
Newcomer
 
Join Date: Apr 2003
Posts: 10
Default

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.
Reply With Quote
  #16  
Old 04-24-2003, 03:31 AM
starbitz's Avatar
starbitz starbitz is offline
Junior Contributor
 
Join Date: Feb 2003
Location: Philippines
Posts: 336
Default

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.
Reply With Quote
  #17  
Old 04-24-2003, 03:34 AM
KreeZiE KreeZiE is offline
Newcomer
 
Join Date: Apr 2003
Posts: 10
Default

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..
Attached Files
File Type: zip Zonnewering.zip (171.3 KB, 5 views)
Reply With Quote
  #18  
Old 04-24-2003, 03:56 AM
starbitz's Avatar
starbitz starbitz is offline
Junior Contributor
 
Join Date: Feb 2003
Location: Philippines
Posts: 336
Default

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.
Reply With Quote
  #19  
Old 04-24-2003, 04:45 PM
unclebill unclebill is offline
Junior Contributor
 
Join Date: Apr 2003
Location: San Diego, CA
Posts: 301
Default

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.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help with my basic math program (beginner) raystorm General 10 04-04-2003 11:33 PM
call another program and obtain status code after program is closed cosito7777 General 1 01-06-2003 02:55 PM
help with program for school brian6561 Miscellaneous Languages 9 10-10-2002 04:02 PM
Need Help using a program that makes use of Timers Unregistered General 5 09-16-2002 06:34 PM
Program for school...Much help needed. Double121 General 1 11-27-2001 08:20 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->