Microsoft Small Basic

Program Listing: SSD540
GraphicsWindow.BackgroundColor = "AliceBlue"
GraphicsWindow.Title = "Timer"
GraphicsWindow.Width = 250
GraphicsWindow.Height = 50

byou = Controls.AddTextBox(60, 10)
hun = Controls.AddTextBox(10, 10)
Controls.SetSize(byou, 40, 20)
Controls.SetSize(hun, 40, 20)
GraphicsWindow.DrawText(52, 10, ":")

botan = Controls.AddButton("|>", 115, 10)
Controls.ButtonClicked = OnClick

pause = Controls.AddButton("Pause", 160, 10)

Sub OnClick
Timer.Interval = 1000
Timer.Tick = countdownevent
If Controls.LastClickedButton = pause then
Timer.Pause()
EndIf
EndSub

Sub countdownevent
byouhyouji = Controls.GetTextBoxText(byou)
hunhyouji = Controls.GetTextBoxText(hun)
totaltime = hunhyouji * 60 + byouhyouji
If totaltime > 0 then
totaltime = totaltime - 1
huntime = Math.Floor(totaltime / 60)
byoutime = Math.Remainder(totaltime, 60)
Controls.SetTextBoxText(byou, byoutime)
Controls.SetTextBoxText(hun, huntime)
EndIf
If totaltime = 0 then
Controls.SetTextBoxText(byou, 0)
Controls.SetTextBoxText(hun, 0)
Sound.PlayChime()
Timer.Pause()
EndIf
EndSub