Advertisement

timer for VB6

Started by August 23, 2002 03:30 AM
3 comments, last by blacktrix 22 years, 6 months ago
hi, sorry if i sound like a newbie, but, I am. I need help programming a Furby (Digimon/Tamagotchi) style application for my school project. I''m having trouble with writing a code so that after every 2 hours or so, it needs to be fed. Is it possible to use the time function (call 1stOutput.AddItem(Hour(Time))) and then calculate the time when the program first starts and then when the hour is called, a pop-up appears? Please help!
AI?





"Making it up! Why should I be making it up. Lifes bad enough as it is without wanting to invent more of it."
"Making it up! Why should I be making it up. Lifes bad enough as it is without wanting to invent more of it."
Advertisement
i think the ai must come in as the "tamagotchi" part... ...

in answer to your question... you can simply put a timer control on the form (assuming you're using one) and set its delay to once a minute or so... you could then, upon loading of the program in the first instance record the start time using "Now" which will give you a time stamp effectively... format it as "dd-mmm-yyyy hh:nn:ss", something like "23-Aug-2002 10:38:45"...

this time stamp should be set to "Now" every time the user feeds the animal...

each time your timer "goes off" you can then check to see if the animal has been fed in the last hour... do something like:
if datediff("h", lastFed, Now) > 1 then   msgbox("feed the damn animal!", vbexclamation + vbokonly)   'the following lines of code should only be put in if you don't want   'the pop-up to keep appearing   lastFed = format(dateadd("n", x, lastFed), "dd-mmm-yyyy hh:nn:ss")end if  

x should be something like five minutes so you'd then get warned every five minutes (or whatever delay you decide)... once the animal has been fed you'd set the lastFed information as "Now" again which will set the effective delay back to 1 hour...

hope that's the sort of thing you were after... ...

[edited by - paulus_maximus on August 23, 2002 6:08:51 AM]

[edited by - paulus_maximus on August 23, 2002 6:09:18 AM]
don't sit back and let life take you where it will...
grab it by the horns and wrestle it to the ground...
you'll only end up talking about missed chances if you don't...
[paulfucius, 2002]
thanks so much paulus_maximus! You''ve been a great help!
not a problem in the slightest... anytime... :D...
don't sit back and let life take you where it will...
grab it by the horns and wrestle it to the ground...
you'll only end up talking about missed chances if you don't...
[paulfucius, 2002]

This topic is closed to new replies.

Advertisement