#Region Project Attributes
#MainFormWidth: 800
#MainFormHeight: 800
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private btnAsk As Button
Private txtQuestion As TextField
Private lblMagicAnswer As Label
Private answers(20) As String
answers(0) = "It Is certain."
answers(1) = "It Is decidedly so."
answers(2) = "Without a doubt."
answers(3) = "Yes – definitely."
answers(4) = "You may rely on it."
answers(5) = "As I see it, Yes."
answers(6) = "Most likely."
answers(7) = "Outlook good."
answers(8) = "Yes."
answers(9) = "Signs point to yes."
answers(10) = "Reply hazy, try again."
answers(11) = "Ask again later."
answers(12) = "Better not tell you now."
answers(13) = "Cannot predict now."
answers(14) = "Concentrate and ask again."
answers(15) = "Don't count on it."
answers(16) = "My reply is No."
answers(17) = "My sources say No."
answers(18) = "Outlook not so good."
answers(19) = "Very doubtful."
Dim lastQuestion As String
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Magic8Ball")
MainForm.Show
End Sub
Sub btnAsk_Click
GiveAnswer
End Sub
Sub txtQuestion_Action
GiveAnswer
End Sub
Sub GiveAnswer
If txtQuestion.Text = "" Then
lblMagicAnswer.Text = "Yes or No Questions Please"
Else if txtQuestion.Text = lastQuestion Then
lblMagicAnswer.Text = "I already answered that"
Else
Dim magicAnswer As Int = Rnd(0, 19)
lblMagicAnswer.Text = answers(magicAnswer)
lastQuestion = txtQuestion.Text
End If
End Sub