English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I'm doing a Puzzle game in VB. For that I need to time the answers. How do I do that?

2006-06-16 18:51:04 · 4 answers · asked by Senthil 3 in Computers & Internet Programming & Design

4 answers

1. Place a Timer control on your form.
2. Set its Interval property to 1000(for 1 sec., 1000 millisec.), so the Timer(or Tick) event will be called every n
milliseconds, determined by the Interval property.
3. Put this code into the Timer(or Tick) event(first define an Integer variable at the top of the form's code):

If seconds = Then
MsgBox("Times up!")
Exit Sub
End If
seconds = seconds + 1

Diring design, you can set the Timer's Enabled property to False to disable the Timer. To change states(enabled/disabled), use:
.Enabled = Not .Enabled

:)

2006-06-25 11:12:37 · answer #1 · answered by _anonymous_ 4 · 0 0

drag and drop a timer into the ur FORM window from the windows components toolbar(let its name be timerForU).. there is a propety for timer called: interval. first set value for it before starting the timer

code: timerForU.interval=500
ie: 500 milliseconds

then to start the timer: timerForU.start()

500 indicates the time in millisec after which the timer will tick. (tick is an event generated by the timer after each 500 ms). ie: tick event arises at: 500ms, 1000ms, 1500ms... till the timer is stopped by stop() method

event handler: to handle the timer tick event:

private sub timerForU_tick(byval sender as System.Object, byval e as System.EventArgs) handles timerForU.Tick
// event handling code goes here
end sub

to sum up:
1.) set interval
2.) start timer
3.) handle events and stop the timer whenevr needed
4.) handle exceptions

2006-06-16 19:25:57 · answer #2 · answered by i_am_the_answer 1 · 0 0

ok since your desgning a game let me give you some advice if you want a better time approx then you need to write a better timing device GetTicks API or the call in .net will do it but if you just need it for rudimentry game loop then a timer (dragged on or invoked in code) and a timmer1.enabled=true; boolean value will dictate what state it is in the tick event will do the trick good luck

- Mike roth

2006-06-16 19:59:51 · answer #3 · answered by Michael R 2 · 0 0

read all about it

2006-06-16 19:14:41 · answer #4 · answered by © 2007. Sammy Z. 6 · 0 0

fedest.com, questions and answers