Am a newbie to scripting doing as an learn on my own kinda thing and in the microsoft wsh & vbscript programming for the absolute beginner there is a challenge at the end of the chapter and am looking to change the code so that it displays the correct answer for any question that the player misses. I open it/modify it in NotePad and dbl click the file to launch Windows Script Host to run the quiz... VBScript
Any help will be appreciated.
Code:
'Perform script initialization activities
Option Explicit
Dim intPlayGame, strSplashImage, strAnswerOne, strAnswerTwo, strAnswerThree
Dim strAnswerFour, strAnswerFive, intNumberCorrect, strFederationRank
Dim objFsoObject
Const cTitlebarMsg = "The Star Trek Quiz Game"
'Start the user's score at zero
intNumberCorrect = 0
'Display the splash screen and ask the user if he or she wants to play
strSplashImage = space(11) & "********" & vbCrLf & _
" ******************" & space(20) & "**************************" & _
space(15) & vbCrLf & "*" & space(30) & "*" & space(18) & _
"**" & space(39) & "*" & vbCrLf & " ******************" & _
space(20) & "*************************" & vbCrLf & space(31) & _
"******" & space(26) & "***" & vbCrLf & _
space(34) & "******" & space(22) & "***" & vbCrLf & _
space(37) & "******" & space(17) & "***" & vbCrLf & _
space(26) & " ****************************" & vbCrLf & _
space(26) & "*******************************" & vbCrLf & _
space(26) & "******************************" & vbCrLf & _
space(26) & " ****************************" & vbCrLf & vbCrLf & vbCrLf & _
"Would you like to boldly go where no one has gone before?"
intPlayGame = MsgBox(strSplashImage, 36, cTitlebarMsg)
If intPlayGame = 6 Then 'User elected to play the game
strAnswerOne = InputBox("What was the Science Officer's name in the " & _
"original Star Trek series?", cTitlebarMsg)
If LCase(strAnswerOne) = "spock" Then
intNumberCorrect = intNumberCorrect + 1
End If
Else 'User doesn't want to play
MsgBox "Thank you for taking the Star Trek Quiz © Jerry Ford 2002." & _
vbCrLf & vbCrLf & "Live long and prosper!", , cTitlebarMsg
WScript.Quit()
End If
strAnswerTwo = InputBox("What Star Trek villain appeared in both the " & _
"original series and a Star Trek movie?", cTitlebarMsg)
If LCase(strAnswerTwo) = "khan" Then
intNumberCorrect = intNumberCorrect + 1
End If
strAnswerThree = InputBox("What was the numeric designation of " & _
"Voyager's on-board Borg?", cTitlebarMsg)
If CStr(strAnswerThree) = "7" Then
intNumberCorrect = intNumberCorrect + 1
ElseIf CStr(strAnswerThree) = "7 of 9" Then
intNumberCorrect = intNumberCorrect + 1
End If
strAnswerFour = InputBox("Name the only Star Trek character to " & _
"regularly appear on two series and at least two Star Trek " & _
"movies?", cTitlebarMsg)
If LCase(strAnswerFour) = "worf" Then
intNumberCorrect = intNumberCorrect + 1
End If
strAnswerFive = InputBox("What is the last name of your favorite " & _
"Captain?", cTitlebarMsg)
If Len(strAnswerFive) > 3 Then
If Instr(1, "kirkpicardsiscojanewayarcher", LCase(strAnswerFive), 1) _
<> 0 Then
intNumberCorrect = intNumberCorrect + 1
End If
End If
Select Case intNumberCorrect
Case 5 'User got all five answers right
strFederationRank = "Admiral"
Case 4 'User got 4 of 5 answers right
strFederationRank = "Captain"
Case 3 'User got 3 of 5 answers right
strFederationRank = "Commander"
Case 2 'User got 2 of 5 answers right
strFederationRank = "Lieutenant-Commander"
Case 1 'User got 1 of 5 answers right
strFederationRank = "Lieutenant"
Case 0 'User did not get any answers right
strFederationRank = "Ensign"
End Select
MsgBox "You answered " & intNumberCorrect & " out of 5 correct." & _
vbCrLf & vbCrLf & "Your Star Fleet rank is : " & _
strFederationRank, , cTitlebarMsg