Wednesday, September 8, 2010

Wednesday, September 8th 2010

Still looking at timers. For the next Michael Halvorson tutorial I will be looking at making a digital clock.

Timers have an interval property which is set using milliseconds (spelled with two "l"s, note to self).

To set the timer to seconds, just set the interval property of the time to 1000 milliseconds.

I expanded the tutorial so that the Start / Stop button was the same


If Timer1.Enabled = False Then
Timer1.Enabled = True
btnBegin.Text = "Stop"
Else
Timer1.Enabled = False
btnBegin.Text = "Begin"
End If


I then fooled around with the mod function to play some "music" with the timer



Dim sec As Integer = DateTime.Now.Second
If sec Mod 2 = 0 And sec Mod 4 <> 0 Then System.Console.Beep(200, 100)
If sec Mod 4 = 0 Then System.Console.Beep(400, 200)
If sec Mod 3 = 0 And sec Mod 5 <> 0 Then System.Console.Beep(300, 100)
If sec Mod 5 = 0 Then System.Console.Beep(100, 150)


I also found a great tutorial site for console apps which I want to work on in a bit

VB Console tutorials

Tomorrow I have a long workday so I am going to try and focus on it.

No comments: