Hallo
I´m new to this group. I hope I´m not going to lower the
tone too
much.
The problem with the code below seems to be in the Private
Sub
mnumchoice_Click()
Any help greatly appreciated. And Merry Christmas of course.
Paul
Option Explicit
Dim QuePreps As Integer ' question number to answer
Prepositions
Dim QueVerbs As Integer ' question number to answer Verbs
Dim Quemul As Integer ' question number to answer muiltiple
choice
questions
Dim Score As Integer ' score
Dim Prepositions(19) As String ' declared array of Phrasal
Verbs by
Prepositions 20 in all
Dim Verbs(19) As String ' declared array of Phrasal
Verbs by
Verbs 20 in all
Private Sub cmdendquiz1_Click() ' ends the quiz answer
Verb/Preps
fratype.Visible = False ' sets the correct values
to
orginal state
mnuoption.Enabled = True ' hides the frame and
shows the
start label
mnuendquiz.Enabled = False
lblstart.Visible = True
Score = 0
QuePreps = 0
End Sub
Private Sub cmdquestion_Click()
' this selects the case QuePreps corresponding to answer
Prepositions type in questions
' here i set it so, if the typed in answer = the correct
Prepositions
()array then
' increase score by 1, then set the next question to the
next team
up in the array
' and increase the question number, i have repeated this for
all
questions
Select Case QuePreps
Case 1
If txtAnswer.Text = Prepositions(0) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(1)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 2
If txtAnswer.Text = Prepositions(1) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(2)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 3
If txtAnswer.Text = Prepositions(2) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(3)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 4
If txtAnswer.Text = Prepositions(3) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(4)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 5
If txtAnswer.Text = Prepositions(4) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(5)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 6
If txtAnswer.Text = Prepositions(5) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(6)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 7
If txtAnswer.Text = Prepositions(6) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(7)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 8
If txtAnswer.Text = Prepositions(7) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(8)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 9
If txtAnswer.Text = Prepositions(8) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(9)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 10
If txtAnswer.Text = Prepositions(9) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(10)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 11
If txtAnswer.Text = Prepositions(10) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(11)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 12
If txtAnswer.Text = Prepositions(11) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(12)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 13
If txtAnswer.Text = Prepositions(12) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(13)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 14
If txtAnswer.Text = Prepositions(13) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(14)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 15
If txtAnswer.Text = Prepositions(14) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(15)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 16
If txtAnswer.Text = Prepositions(15) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(16)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 17
If txtAnswer.Text = Prepositions(16) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(17)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 18
If txtAnswer.Text = Prepositions(17) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(18)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
Case 19
If txtAnswer.Text = Prepositions(18) Then
Score = Score + 1
End If
lblquestion.Caption = Verbs(19)
txtAnswer.Text = ""
QuePreps = QuePreps + 1
' This case is the same in adding the score but instead of
moving
onto the
' next question i have have displayed the score by msgbox
and once
the user clicks
' ok the quiz ends and all values are set to there orginal
state
ready for another
' quiz to take place
Case 20
If txtAnswer.Text = Prepositions(19) Then
Score = Score + 1
End If
txtAnswer.Text = ""
MsgBox "You scored " & Score & " Out
of 20 correct, Press okay to
end quiz", vbOKOnly, "Score"
fratype.Visible = False
lblstart.Visible = True
mnuendquiz.Enabled = False
mnuoption.Enabled = True
Score = 0
QuePreps = 0
End Select
' this selects the case QueVerbs corresponding to answer
Verbs type
in questions
' here i set it so, if the typed in answer = the correct
Verbs()
array then
' increase score by 1, then set the next question to the
next team
up in the array
' and increase the question number, i have repeated this for
all
questions
Select Case QueVerbs
Case 1
If txtAnswer.Text = Verbs(0) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(1)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 2
If txtAnswer.Text = Verbs(1) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(2)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 3
If txtAnswer.Text = Verbs(2) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(3)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 4
If txtAnswer.Text = Verbs(3) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(4)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 5
If txtAnswer.Text = Verbs(4) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(5)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 6
If txtAnswer.Text = Verbs(5) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(6)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 7
If txtAnswer.Text = Verbs(6) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(7)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 8
If txtAnswer.Text = Verbs(7) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(8)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 9
If txtAnswer.Text = Verbs(8) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(9)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 10
If txtAnswer.Text = Verbs(9) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(10)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 11
If txtAnswer.Text = Verbs(10) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(11)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 12
If txtAnswer.Text = Verbs(11) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(12)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 13
If txtAnswer.Text = Verbs(12) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(13)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 14
If txtAnswer.Text = Verbs(13) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(14)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 15
If txtAnswer.Text = Verbs(14) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(15)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 16
If txtAnswer.Text = Verbs(15) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(16)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 17
If txtAnswer.Text = Verbs(16) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(17)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 18
If txtAnswer.Text = Verbs(17) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(18)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
Case 19
If txtAnswer.Text = Verbs(18) Then
Score = Score + 1
End If
lblquestion.Caption = Prepositions(19)
txtAnswer.Text = ""
QueVerbs = QueVerbs + 1
' This case is the same in adding the score but instead of
moving
onto the
' next question i have have displayed the score by msgbox
and once
the user clicks
' ok the quiz ends and all values are set to their orginal
state
ready for another
' quiz to take place
Case 20
If txtAnswer.Text = Verbs(19) Then
Score = Score + 1
End If
txtAnswer.Text = ""
MsgBox "You scored " & Score & " Out
of 20 correct, Press okay to
end quiz", vbOKOnly, "Score"
fratype.Visible = False
lblstart.Visible = True
mnuendquiz.Enabled = False
mnuoption.Enabled = True
Score = 0
QueVerbs = 0
End Select
End Sub
Private Sub Form_Load()
' here i have set all the string values in the Prepositions
and
Verbs array to
' correct Preposition/Verb, the Verbs are put into
alphabetical
order and the
' Prepositions are in the order of the Verbs, so
Prepositions(3) is
the preposition of verb(3)
Prepositions(0) = "Highbury"
Prepositions(1) = "Villa Park"
Prepositions(2) = "St Andrews"
Prepositions(3) = "Ewood Park"
Prepositions(4) = "Reebok Stadium"
Prepositions(5) = "The Valley"
Prepositions(6) = "Stamford"
Prepositions(7) = "Selhurst Park"
Prepositions(8) = "Goodison Park"
Prepositions(9) = "Craven Cottage"
Prepositions(10) = "Anfield"
Prepositions(11) = "City of Manchester Stadium"
Prepositions(12) = "Old Trafford"
Prepositions(13) = "The Riverside Stadium"
Prepositions(14) = "St james Park"
Prepositions(15) = "Carrow Road"
Prepositions(16) = "Fratton Park"
Prepositions(17) = "The Friends Provident St Mary's
Stadium"
Prepositions(18) = "White Hart Lane"
Prepositions(19) = "The Hawthorns"
Verbs(0) = "Arsenal"
Verbs(1) = "Aston Villa"
Verbs(2) = "Birmingham City"
Verbs(3) = "Blackburn Rovers"
Verbs(4) = "Bolton Wanderers"
Verbs(5) = "Charlton Athletic"
Verbs(6) = "Chelsea"
Verbs(7) = "Crystal Palace"
Verbs(8) = "Everton"
Verbs(9) = "Fulham"
Verbs(10) = "Liverpool"
Verbs(11) = "Manchester City"
Verbs(12) = "Manchester United"
Verbs(13) = "Middlesbrough"
Verbs(14) = "Newcastle United"
Verbs(15) = "Norwich City"
Verbs(16) = "Portsmouth"
Verbs(17) = "Southampton"
Verbs(18) = "Tottenham Hotspur"
Verbs(19) = "West Bromwich Albion"
Randomize
End Sub
Private Sub mnuendquiz_Click() ' This ends the quiz for all
question
types
mnuoption.Enabled = True ' sets all the values to the
orginal
state
mnuendquiz.Enabled = False ' hides both frames and shows
the
label start
lblstart.Visible = True ' this baically puts the
program into
the start up
Score = 0 ' state
QuePreps = 0
QueVerbs = 0
Quemul = 0
framulti.Visible = False
fratype.Visible = False
End Sub
Private Sub mnuexit_Click()
End ' ends program
End Sub
Private Sub mnumchoice_Click()
framulti.Visible = True ' Once clicked it starts the
multible
choice
Quemul = 1 ' questions, sets the
question value
(quemul) to 1
Score = 0 ' shows the correct frame
hides start
label and puts
lblstart.Visible = False ' buts the optanswer array
captions 1
being the top
lblVerbs.Caption = Verbs(0) ' as the correct
Preposition, and
the reminding 3 as incorrect
optanswer.Item(3).Caption = Prepositions(0)
optanswer.Item(0).Caption = Prepositions(4)
optanswer.Item(1).Caption = Prepositions(16)
optanswer.Item(2).Caption = Prepositions(19)
lblscore.Caption = Score ' shows score so far
optdunno.Value = True ' optdunno vaule is set to true this
makes
the user have to
mnuoption.Enabled = False ' click an answer to advance
mnuendquiz.Enabled = True ' all the of menus are set to
the
correct enabled property
End Sub ' for the set of questions
Private Sub mnusta_Click()
QuePreps = 1 ' This mnusub is to
answer
Prepositions question set
Score = 0 ' sets the
question(QuePreps) to 1
score to 0
lblquestion.Caption = Verbs(0) ' sets the question to the
first
Verb
fratype.Visible = True ' fratype where the controls
are
held is made visible
lblstart.Visible = False ' the label start is now
hidden
mnuoption.Enabled = False ' the mnus are set to the
right
enabled property
mnuendquiz.Enabled = True
End Sub
Private Sub mnuteam_Click()
QueVerbs = 1 ' this mnusub is
excatly the
same as mnusta
Score = 0 ' other than having a
different
question name
lblquestion.Caption = Prepositions(0) ' and it sets the
question as
Prepositions rather than
fratype.Visible = True ' Verb
lblstart.Visible = False
mnuoption.Enabled = False
mnuendquiz.Enabled = True
End Sub
Private Sub optanswer_Click(Index As Integer)
' for each time an optanswer choice box is pressed it calls
on
' the select case quemul (multi choiced question number)
' if the correct optanwer is clicked 1 is added to the score
' then moves onto settin 1 of the opt to the correct
Preposition and
the reminding 3
' to incorrect, i have done this rather than randoming the
(number)
becuase
' i had problems of having the same answer 2 times in the
array
cause for confusion
' the same process is carried out until case 21 (commented
on)
Quemul = Quemul + 1
Select Case Quemul
Case 2
If optanswer.Item(3).Value = True Then
Score = Score + 1
End If
optanswer.Item(0).Caption = Prepositions(1)
optanswer.Item(1).Caption = Prepositions(3)
optanswer.Item(2).Caption = Prepositions(12)
optanswer.Item(3).Caption = Prepositions(6)
lblVerbs = Verbs(1)
optdunno.Value = True
Case 3
If optanswer.Item(0).Value = True Then
Score = Score + 1
End If
optanswer.Item(2).Caption = Prepositions(2)
optanswer.Item(0).Caption = Prepositions(19)
optanswer.Item(1).Caption = Prepositions(10)
optanswer.Item(3).Caption = Prepositions(7)
lblVerbs = Verbs(2)
optdunno.Value = True
Case 4
If optanswer.Item(2).Value = True Then
Score = Score + 1
End If
optanswer.Item(1).Caption = Prepositions(3)
optanswer.Item(0).Caption = Prepositions(11)
optanswer.Item(2).Caption = Prepositions(15)
optanswer.Item(3).Caption = Prepositions(2)
lblVerbs = Verbs(3)
optdunno.Value = True
Case 5
If optanswer.Item(1).Value = True Then
Score = Score + 1
End If
optanswer.Item(1).Caption = Prepositions(4)
optanswer.Item(0).Caption = Prepositions(16)
optanswer.Item(2).Caption = Prepositions(7)
optanswer.Item(3).Caption = Prepositions(13)
lblVerbs = Verbs(4)
optdunno.Value = True
Case 6
If optanswer.Item(1).Value = True Then
Score = Score + 1
End If
optanswer.Item(0).Caption = Prepositions(5)
optanswer.Item(1).Caption = Prepositions(6)
optanswer.Item(2).Caption = Prepositions(10)
optanswer.Item(3).Caption = Prepositions(15)
lblVerbs = Verbs(5)
optdunno.Value = True
Case 7
If optanswer.Item(0).Value = True Then
Score = Score + 1
End If
optanswer.Item(3).Caption = Prepositions(6)
optanswer.Item(0).Caption = Prepositions(18)
optanswer.Item(1).Caption = Prepositions(9)
optanswer.Item(2).Caption = Prepositions(17)
lblVerbs = Verbs(6)
optdunno.Value = True
Case 8
If optanswer.Item(3).Value = True Then
Score = Score + 1
End If
optanswer.Item(2).Caption = Prepositions(7)
optanswer.Item(0).Caption = Prepositions(3)
optanswer.Item(1).Caption = Prepositions(16)
optanswer.Item(3).Caption = Prepositions(8)
lblVerbs = Verbs(7)
optdunno.Value = True
Case 9
If optanswer.Item(2).Value = True Then
Score = Score + 1
End If
optanswer.Item(1).Caption = Prepositions(8)
optanswer.Item(0).Caption = Prepositions(13)
optanswer.Item(2).Caption = Prepositions(15)
optanswer.Item(3).Caption = Prepositions(7)
lblVerbs = Verbs(8)
optdunno.Value = True
Case 10
If optanswer.Item(1).Value = True Then
Score = Score + 1
End If
optanswer.Item(3).Caption = Prepositions(9)
optanswer.Item(0).Caption = Prepositions(5)
optanswer.Item(1).Caption = Prepositions(1)
optanswer.Item(2).Caption = Prepositions(18)
lblVerbs = Verbs(9)
optdunno.Value = True
Case 11
If optanswer.Item(3).Value = True Then
Score = Score + 1
End If
optanswer.Item(0).Caption = Prepositions(10)
optanswer.Item(2).Caption = Prepositions(0)
optanswer.Item(1).Caption = Prepositions(14)
optanswer.Item(3).Caption = Prepositions(3)
lblVerbs = Verbs(10)
optdunno.Value = True
Case 12
If optanswer.Item(0).Value = True Then
Score = Score + 1
End If
optanswer.Item(2).Caption = Prepositions(11)
optanswer.Item(0).Caption = Prepositions(12)
optanswer.Item(1).Caption = Prepositions(1)
optanswer.Item(3).Caption = Prepositions(2)
lblVerbs = Verbs(11)
optdunno.Value = True
Case 13
If optanswer.Item(2).Value = True Then
Score = Score + 1
End If
optanswer.Item(2).Caption = Prepositions(12)
optanswer.Item(0).Caption = Prepositions(17)
optanswer.Item(1).Caption = Prepositions(6)
optanswer.Item(3).Caption = Prepositions(15)
lblVerbs = Verbs(12)
optdunno.Value = True
Case 14
If optanswer.Item(2).Value = True Then
Score = Score + 1
End If
optanswer.Item(1).Caption = Prepositions(13)
optanswer.Item(0).Caption = Prepositions(19)
optanswer.Item(2).Caption = Prepositions(0)
optanswer.Item(3).Caption = Prepositions(16)
lblVerbs = Verbs(13)
optdunno.Value = True
Case 15
If optanswer.Item(1).Value = True Then
Score = Score + 1
End If
optanswer.Item(0).Caption = Prepositions(14)
optanswer.Item(2).Caption = Prepositions(13)
optanswer.Item(1).Caption = Prepositions(5)
optanswer.Item(3).Caption = Prepositions(8)
lblVerbs = Verbs(14)
optdunno.Value = True
Case 16
If optanswer.Item(0).Value = True Then
Score = Score + 1
End If
optanswer.Item(3).Caption = Prepositions(15)
optanswer.Item(0).Caption = Prepositions(18)
optanswer.Item(1).Caption = Prepositions(3)
optanswer.Item(2).Caption = Prepositions(12)
lblVerbs = Verbs(15)
optdunno.Value = True
Case 17
If optanswer.Item(3).Value = True Then
Score = Score + 1
End If
optanswer.Item(2).Caption = Prepositions(16)
optanswer.Item(0).Caption = Prepositions(13)
optanswer.Item(1).Caption = Prepositions(4)
optanswer.Item(3).Caption = Prepositions(7)
lblVerbs = Verbs(16)
optdunno.Value = True
Case 18
If optanswer.Item(2).Value = True Then
Score = Score + 1
End If
optanswer.Item(0).Caption = Prepositions(17)
optanswer.Item(2).Caption = Prepositions(5)
optanswer.Item(1).Caption = Prepositions(1)
optanswer.Item(3).Caption = Prepositions(0)
lblVerbs = Verbs(17)
optdunno.Value = True
Case 19
If optanswer.Item(0).Value = True Then
Score = Score + 1
End If
optanswer.Item(1).Caption = Prepositions(18)
optanswer.Item(0).Caption = Prepositions(14)
optanswer.Item(2).Caption = Prepositions(10)
optanswer.Item(3).Caption = Prepositions(19)
lblVerbs = Verbs(18)
optdunno.Value = True
Case 20
If optanswer.Item(1).Value = True Then
Score = Score + 1
End If
optanswer.Item(2).Caption = Prepositions(19)
optanswer.Item(0).Caption = Prepositions(8)
optanswer.Item(1).Caption = Prepositions(16)
optanswer.Item(3).Caption = Prepositions(2)
lblVerbs = Verbs(19)
optdunno.Value = True
' here case 21 like the previous cases if the correct
optanswer is
pressed
' it adds 1 to the score, but instead of moving onto the
next
question it displays
' the score by msgbox and all the controls for this set of
questions
are set to the
' correct propertys to start the quiz once again
Case 21
If optanswer.Item(2).Value = True Then
Score = Score + 1
End If
MsgBox "You scored " & Score & " out
of 20", vbOKOnly, "Score"
lblstart.Visible = True
Score = 0
Quemul = 0
framulti.Visible = False
mnuendquiz.Enabled = False
mnuoption.Enabled = True
End Select
lblscore.Caption = Score ' updates score each optanswer(i)
click
End Sub
Private Sub txtAnswer_KeyPress(KeyAscii As Integer) ' This
sub for
txtanswer
If KeyAscii = vbKeyReturn Then ' gets
the
keyascii code for
cmdquestion_Click ' the
return
key, once pressed
End If ' call
on the
question button
If KeyAscii = 13 Then KeyAscii = 0 ' stops the beep
sound each
time the return key is pressed
If KeyAscii >= vbKey0 And KeyAscii <= vbKey9 Then '
here we stop
the user from entering
KeyAscii = 0 '
numbers, and
greated by a message
MsgBox "You cannot enter digits", vbOKOnly +
vbInformation, "Incorrect keypress"
End If
End Sub
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://grou
ps.yahoo.com/group/helpwithvb/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://
groups.yahoo.com/group/helpwithvb/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:helpwithvb-digest@yahoogroups.com
mailto:helpwithvb-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
helpwithvb-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|