まずは事前に何か助けていただきありがとうございます。VBScript for rock、paper、scissors outcome
私はVBScriptを使用して学校のスクリプトを作成しています。私は過去にこのスクリプトを使ったことは一度もありませんでしたが、使用するにはあまりにもひどいとは思われません。私が取り組んでいる課題は、ゲームの結果に結果表示を追加することです。以下は私がこれまで持っていたものです。すべての "IF"ステートメントを使用すると、スクリプトは実行されますが、すべてのゲーム結果が表示されます。 "IF"ステートメントを "ELSEIF"ステートメントに変更すると、結果スクリプトの2行目の "THEN"ステートメントで始まる構文エラーが返されます。誰かが私が逃したものや私が間違ってやったことについて正しい方向に向けることができますか?時間と配慮をしてくれてありがとう。
'Formally declare variables used by the script before trying to use them
Dim WshShl, Answer, CardImage
'Create an instance of the WScript object in order to later use the
'Popup method
Set WshShl = WScript.CreateObject("WScript.Shell")
'Input for player name
Reply1 = InputBox("Hello. What is your name?")
'Display greeting and player name
MsgBox "Hello " & Reply1 & "! Welcome to Rock, Paper Scissors!"
'Display the rules of the game
WshShl.Popup "Welcome to Rock, Paper and Scissors game. Here are the " & _
"rules of the game: 1. Guess the same thing as the computer " & _
"to tie. 2. Paper covers rock and wins. 3. Rock breaks " & _
"scissors and wins. 4. Scissors cut paper and wins."
'Prompt the user to select a choice
Answer = InputBox("Type Paper, Rock, or Scissors.", _
"Let's play a game!")
'Time for the computer to randomly pick a choice
Randomize
GetRandomNumber = Round(FormatNumber(Int((3 * Rnd()) + 1)))
'Assign a value to the randomly selected number
If GetRandomNumber = 3 then CardImage = "rock"
If GetRandomNumber = 2 then CardImage = "scissor"
If GetRandomNumber = 1 then CardImage = "paper"
'Display the game's results so that the user can see if he or she won
WshShl.Popup "You picked: " & Answer & Space(12) & "Computer picked: " & _
CardImage
If Answer = "Rock" & Computer <> "Paper" Then MsgBox "Paper Covers Rock: Computer Wins"
ElseIfAnswer = "Paper" & Computer <> "Scissors" Then MsgBox "Scissors Cuts Paper: Computer Wins"
ElseIfAnswer = "Scissors" & Computer <> "Rock" Then MsgBox "Rock Breaks Scissors: Computer Wins"
ElseIfComputer = "Rock" & Answer <> "Paper" Then MsgBox "Paper Covers Rock: You Win "
ElseIfComputer = "Paper" & Answer <> "Scissors" Then MsgBox "Scissors Cuts Paper: You Win "
ElseIfComputer = "Scissors" & Answer <> "Rock" Then MsgBox "Rock Breaks Scissors: You Win "
ElseIfComputer = "Rock" & Answer <> "Rock" Then MsgBox "TIE "
ElseIfComputer = "Paper" & Answer <> "Paper" Then MsgBox "TIE "
Else Computer = "Scissor" & Answer <> "Scissor" Then MsgBox "TIE "
End If
を私はもともとそれがその行の最初の文字で構文エラーを返す「のElseIf」ステートメントの後にスペースを持っていました。 – BreezyHamilton