Microsoft Small Basic

Program Listing: CCS550
' Even or Odd (2012/Sep)
' by Joman Mied
' remix by GoToLoop

'http://social.msdn.microsoft.com/Forums/en-US/smallbasic
'/thread/88d814da-7691-4103-9785-6886f5cb9105

GraphicsWindow.Title = "Is your number Even or Odd?"
GraphicsWindow.CanResize = "False"
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.BrushColor = "Red"
GraphicsWindow.FontBold = "True"

GraphicsWindow.Width = 300
GraphicsWindow.Height = 150
GraphicsWindow.Left = (Desktop.Width - GraphicsWindow.Width ) / 2
GraphicsWindow.Top = (Desktop.Height - GraphicsWindow.Height) / 2

GraphicsWindow.DrawText(70, 0, "Enter your number below:")

GraphicsWindow.BrushColor = "Blue"
NumberBox = Controls.AddTextBox(35, 50)

GraphicsWindow.BrushColor = "Green"
Controls.AddButton("Calculate", 200, 48)

Controls.ButtonClicked = OnButtonClicked

Sub OnButtonClicked

Btn = Controls.GetButtonCaption( Controls.LastClickedButton )
Sound.PlayClick()

If Btn = "Calculate" Then

UsersNumber = Controls.GetTextBoxText(NumberBox) * 1
Num = Math.Remainder(UsersNumber, 2)

GraphicsWindow.BrushColor = GraphicsWindow.BackgroundColor
GraphicsWindow.FillRectangle(100,100 200,100)
GraphicsWindow.BrushColor = "Yellow"

If Num = 0 Then
GraphicsWindow.DrawText(100, 100, UsersNumber + " is even!")
Else
GraphicsWindow.DrawText(100, 100, UsersNumber + " is odd!")
EndIf

Controls.SetTextBoxText(NumberBox, "")

EndIf

EndSub