Hey guys
So,I have this application where there will be ALOT of questions which will be sorted using subs.
I did of course only add 3 questions under development so that the code wont be as huge.
I have built a Small C# program which will create this for me but with the real questions so that I can copy and paste them all
Thats the reason to that this code must be simple and the heavy part must be somewhere else...
My code sofar:
So,How do I get "new_question" to randomly choose from the "questions-subs"?
This is what should happen:
1.The user clicks on one of the buttons
2.he gets a a MSGbox with "Wrong" or "correct"
3.The application randomly chooses another question sub
Like that over and over
Thank you
Thestar19
PS
I have ofcourse created layouts called main and page1
So,I have this application where there will be ALOT of questions which will be sorted using subs.
I did of course only add 3 questions under development so that the code wont be as huge.
I have built a Small C# program which will create this for me but with the real questions so that I can copy and paste them all
Thats the reason to that this code must be simple and the heavy part must be somewhere else...
B4X:
Sub question_2
question.Text = "How many goals?"
answer1.Text = "10"
answer2.Text = "20"
answer3.Text = "30"
correct.Text = "1"
End Sub
My code sofar:
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim dev_screen As Button
Dim go_to_test As Button
Dim nothing_yet As Button
Dim answer1 As Button
Dim answer2 As Button
Dim answer3 As Button
Dim question As Label
Dim correct As Label
Dim Panel1 As Panel
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub nothing_yet_Click
Msgbox("I said NOTHING YET!","Dumass")
End Sub
Sub go_to_test_Click
Msgbox("Laddar","Info")
Activity.LoadLayout("page1")
CallSub(new_question,"new_question")
End Sub
Sub dev_screen_Click
Msgbox("None","Info")
CallSub(question_1,"question1")
End Sub
Sub question_Click
Msgbox("The question is:","Information")
End Sub
Sub answer3_Click
If correct.Text = "3" Then
Msgbox("Correct","Info")
CallSub(new_question,"new_question")
End If
If correct.Text = "1" OR "2" Then
Msgbox("Wrong!","Info")
End If
End Sub
Sub answer2_Click
If correct.Text = "2" Then
Msgbox("Correct","Info")
CallSub(new_question,"new_question")
End If
If correct.Text = "1" OR "3" Then
Msgbox("Wrong!","Info")
End If
End Sub
Sub answer1_Click
If correct.Text = "1" Then
Msgbox("Correct","Info")
CallSub(new_question,"new_question")
End If
If correct.Text = "2" OR "3" Then
Msgbox("Wrong!","Info")
End If
End Sub
Sub Activity_Touch (Action As Int, X As Float, Y As Float)
End Sub
Sub new_question
CallSub(question_1,"question_1")
End Sub
Sub question_1
question.Text = "Who is the best refree?"
answer1.Text = "Emma"
answer2.Text = "Alexander"
answer3.Text = "Per"
correct.Text = "2"
End Sub
Sub question_2
question.Text = "How many goals?"
answer1.Text = "10"
answer2.Text = "20"
answer3.Text = "30"
correct.Text = "1"
End Sub
So,How do I get "new_question" to randomly choose from the "questions-subs"?
This is what should happen:
1.The user clicks on one of the buttons
2.he gets a a MSGbox with "Wrong" or "correct"
3.The application randomly chooses another question sub
Like that over and over
Thank you
Thestar19
PS
I have ofcourse created layouts called main and page1