correct.txt
Sub MAIN
Dim Ans$(5)
' Correct Answers
Ans$(1) = "ce que"
Ans$(2) = "ce qui"
Ans$(3) = "ce qui"
Ans$(4) = "ce que"
Ans$(5) = "ce qui"
' Correct answer counter
Correct = 0
For i = 1 To 5
' Construct the target
Target$ = "[" + LTrim$(Str$(i)) + "]"
' Show Everything to find the hidden targets
ShowAll 1
' Go to the beggining of the document
StartOfWindow
EditFind .Find = Target$, .Direction = 0, .MatchCase = 0, .WholeWord = 0, .PatternMatch = 0, .SoundsLike = 0, .Format = 0, .Wrap = 2, .FindAllWordForms = 0
' Hide them again
ShowAll 0
' If the target is found
If EditFindFound() Then
' Select the next 2 words
WordRight 1
WordRight 2, 1
' Get the user reponse
Answer$ = RTrim$(GetText$(GetSelStartPos(), GetSelEndPos()))
' Did he answered anything?
If Left$(Answer$, 1) = "_" Then
' Exit from macro
MsgBox "Vous n'avez pas fini", "Info"
Goto Exit
ElseIf Answer$ = Ans$(i) Then
' Answer was correct
MsgBox "Correcte reponse!", "Bravo"
Correct = Correct + 1
Else
' Wrong answer
MsgBox "La correcte reponse c'est: " + Ans$(i), "Faut"
End If
Else
MsgBox "Vous avez change le texte. Recommencez", "Info"
Goto Exit
End If
Next i
' Show the user score
MsgBox "Vous avez donne" + Str$(Correct) + " reponses correctes de 5", "Score"
Exit:
End Sub
Vivian Synteta