Error from one of the sample here

hirwansaini

New Member
Licensed User
Longtime User
Hello b4a, newbie here...and in dire need of help.
Downloaded on of the sample quiz from here
http://www.b4x.com/forum/basic4andr...448-how-implement-multiple-choice-quiz-2.html

and got some errors..

http://i6.photobucket.com/albums/y234/headwan/error_zps529c02bb.png

Please do assist me:sign0104:
code as follow:-

'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 Map1 As Map
Dim ListView1 As ListView
Dim rbAnswer1 As RadioButton
Dim rbAnswer2 As RadioButton
Dim rbAnswer3 As RadioButton
Dim TheQuestion As Int
Dim QuestionNumber As Int
Dim CorrectAnswer As String
Dim lblActualQuestion As Label
Dim lblQuestionNumber As Label
Dim Button1 As Button

End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("Main")
QuestionNumber = 1
RandomizeQuestions
Map1.Initialize

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub RandomizeQuestions

lblQuestionNumber.text = QuestionNumber

''''''''''''''''''''
'Initialize the Map'
''''''''''''''''''''
Map1.Initialize

'''''''''''''''''''''''''''''''''''''''''''
'Use the map to create true random numbers'
'''''''''''''''''''''''''''''''''''''''''''
Do While Map1.Size < 5

Map1.Put(Rnd(1, 6), "")

Loop

'''''''''''''''''''''''''''''''''''''''''''''''''''
'Take the random numbers and assign them to a list'
'''''''''''''''''''''''''''''''''''''''''''''''''''
For i = 0 To Map1.Size - 1
ListView1.AddSingleLine(Map1.GetKeyAt(i))
Next

''''''''''''''''''''''''''''''
'Grab the first random number'
''''''''''''''''''''''''''''''
TheQuestion = ListView1.GetItem(0)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Get the question that corresponds to the correct number'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
GetQuestion

End Sub

Sub GetQuestion

''''''''''''''''''''''''''''''''''''''''''
'Create questions randomly and on the fly'
''''''''''''''''''''''''''''''''''''''''''

If TheQuestion = 1 Then
lblActualQuestion.text = "What number is found in Basic4Android?"
rbAnswer1.Text = "2"
rbAnswer2.Text = "3"
rbAnswer3.Text = "4"
CorrectAnswer = "4"
End If

If TheQuestion = 2 Then
lblActualQuestion.text = "Do you understand this example?"
rbAnswer1.Text = "Yes"
rbAnswer2.Text = "No"
rbAnswer3.Text = "Sort of?"
CorrectAnswer = "Yes"
End If

If TheQuestion = 3 Then
lblActualQuestion.text = "What color is the sky?"
rbAnswer1.Text = "Red"
rbAnswer2.Text = "Green"
rbAnswer3.Text = "Blue"
CorrectAnswer = "Blue"
End If

If TheQuestion = 4 Then
lblActualQuestion.text = "Who made this tutorial?"
rbAnswer1.Text = "Erel"
rbAnswer2.Text = "PharCyDeD"
rbAnswer3.Text = "klaus"
CorrectAnswer = "PharCyDeD"
End If

If TheQuestion = 5 Then
lblActualQuestion.text = "Which seach engine is most popular?"
rbAnswer1.Text = "Ask Jeeves"
rbAnswer2.Text = "Google"
rbAnswer3.Text = "Dogpile"
CorrectAnswer = "Google"
End If

End Sub

Sub Button1_Click

'''''''''''''''''''''''''''''''''''''''''''''''''''''
'Check the answer submitted to determine right/wrong'
'''''''''''''''''''''''''''''''''''''''''''''''''''''
If rbAnswer1.Checked = True Then
If rbAnswer1.Text = CorrectAnswer Then
Msgbox("Correct", "You are....")
Else
Msgbox("Wrong!", "You are....")
End If
End If

If rbAnswer2.Checked = True Then
If rbAnswer2.Text = CorrectAnswer Then
Msgbox("Correct", "You are....")
Else
Msgbox("Wrong!", "You are....")
End If
End If

If rbAnswer3.Checked = True Then
If rbAnswer3.Text = CorrectAnswer Then
Msgbox("Correct", "You are....")
Else
Msgbox("Wrong!", "You are....")
End If
End If

'''''''''''''''''''''''''''''''''''''''
'Reset radio buttons for next question'
'''''''''''''''''''''''''''''''''''''''
rbAnswer1.Checked = False
rbAnswer2.Checked = False
rbAnswer3.Checked = False

''''''''''''''''''''''''''''
'Update the question number'
''''''''''''''''''''''''''''
QuestionNumber = QuestionNumber + 1

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Update the label so it says the correct question number'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
lblQuestionNumber = QuestionNumber


If QuestionNumber = 2 Then

TheQuestion = ListView1.GetItem(1)
GetQuestion

End If


If QuestionNumber = 3 Then

TheQuestion = ListView1.GetItem(2)
GetQuestion

End If

If QuestionNumber = 4 Then

TheQuestion = ListView1.GetItem(3)
GetQuestion

End If

If QuestionNumber = 5 Then

TheQuestion = ListView1.GetItem(4)
GetQuestion

End If

If QuestionNumber > 5 Then

Msgbox("Quiz Over!", "You made it to the end!")

End If

End Sub
 
Top