ここでは完全に迷っています。私は週末のうちに壁に向かって頭を打ち、私の人生は私のプログラムの仕事をどうやって作るかを考え出すことができません。これはカレッジクラスの課題であり、私の最初のプログラミング課題です。これは私にとって本当の課題です。私の指が出血するまで(本当はではない)私はグーグルで行きました。ここに私の割り当ては(私は、フォーマットが間違っを取得する場合、私は深く申し訳ありません)です:VBScript番号推測ゲーム
'Initialization Section
Option Explicit
Const cGreetingMsg = "Pick a number between 1 - 100"
Dim intUserNumber, intRandomNo, strOkToEnd, intNoGuesses
intNoGuesses = 0
'Main Processing Section
'Generate a random number
Randomize
intRandomNo = FormatNumber(Int((100 * Rnd) + 1))
'Loop until either the user guesses correctly or the user clicks on Cancel
Do Until strOkToEnd = "yes"
'Prompt user to pick a number
intUserNumber = InputBox("Type your guess:",cGreetingMsg)
intNoGuesses = intNoGuesses + 1
'See if the user provided an answer
If Len(intUserNumber) <> 0 Then
'Make sure that the player typed a number
If IsNumeric(intUserNumber) = True Then
'Test to see if the user's guess was correct
If FormatNumber(intUserNumber) = intRandomNo Then
MsgBox "Congratulations! You guessed it. The number was " & _
intUserNumber & "." & vbCrLf & vbCrLf & "You guessed it " & _
"in " & intNoGuesses & " guesses.", ,cGreetingMsg
strOkToEnd = "yes"
End If
'Test to see if the user's guess was too low
'Assignment 3: Add another If/ElseIf/Else Condition to check for if the user is less than
'80,60,40,20,10 or farther from the correct guess, but still too low
If FormatNumber(intUserNumber) < intRandomNo Then
strOkToEnd = "no"
End If
'Test to see if the user's guess was too high
'Assignment 3: Add another If/ElseIf/Else Condition to check for if the user is more than
'80,60,40,20,10 or closer to the correct guess, but still too high
If FormatNumber(intUserNumber) > intRandomNo Then
strOkToEnd = "no"
End If
Else
MsgBox "Sorry. You did not enter a number. Try again.", , cGreetingMsg
End If
Else
MsgBox "You either failed to type a value or you clicked on Cancel. " & _
"Please play again soon!", , cGreetingMsg
strOkToEnd = "yes"
End If
Loop
これが私の心を吹いています。リモートで役立つ唯一のものは、このリンク:VBScript Guess a numberであり、私は自分のコードにそのコードをどのように実装するのかについては考えていません。それはうまくいくように見えますが、私がVBScriptを試してみると、「予想される文末」のエラーが発生します。私自身のコードは努力の中では無駄なものですが、ここにあります:
'Initialization Section
Option Explicit
Const cGreetingMsg = "Pick a number between 1 - 100"
Dim intUserNumber, intRandomNo, strOkToEnd, intNoGuesses
intNoGuesses = 0
'Main Processing Section
'Generate a random number
Randomize
intRandomNo = FormatNumber(Int((100 * Rnd) + 1))
'Loop until either the user guesses correctly or the user clicks on Cancel
Do Until strOkToEnd = "yes"
'Prompt user to pick a number
intUserNumber = InputBox("Type your guess:",cGreetingMsg)
intNoGuesses = intNoGuesses + 1
'See if the user provided an answer
If Len(intUserNumber) <> 0 Then
'Make sure that the player typed a number
If IsNumeric(intUserNumber) = True Then
'Test to see if the user's guess was correct
If FormatNumber(intUserNumber) = intRandomNo Then
MsgBox "Congratulations! You guessed it. The number was " & _
intUserNumber & "." & vbCrLf & vbCrLf & "You guessed it " & _
"in " & intNoGuesses & " guesses.", ,cGreetingMsg
strOkToEnd = "yes"
End If
'Test to see if the user's guess was too low
If FormatNumber(intUserNumber) < intRandomNo - 80 Then
MsgBox "Your guess was too low by 80. Try again", ,cGreetingMsg
ElseIf FormatNumber(intUserNumber) < intRandomNo - 60 Then
MsgBox "Your guess was too low by 60. Try again", ,cGreetingMsg
ElseIf FormatNumber(intUserNumber) < intRandomNo - 40 Then
MsgBox "Your guess was too low by 40. Try again", ,cGreetingMsg
ElseIf FormatNumber(intUserNumber) < intRandomNo - 20 Then
MsgBox "Your guess was too low by 20. Try again", ,cGreetingMsg
Elseif FormatNumber(intUserNumber) < intRandomNo - 10 Then
MsgBox "Your guess was too low by 10. Try again", ,cGreetingMsg
ElseIf FormatNumber(intUserNumber) > intRandomNo Then
MsgBox "Your guess was still too low. Try again, please", ,cGreetingMsg
strOkToEnd = "no"
End If
'Test to see if the user's guess was too high
If FormatNumber(intUserNumber) > intRandomNo - 80 Then
MsgBox "Your guess was too high by 80. Try again", ,cGreetingMsg
ElseIf FormatNumber(intUserNumber) > intRandomNo + 60 Then
MsgBox "Your guess was too high by 60. Try again", ,cGreetingMsg
ElseIf FormatNumber(intUserNumber) > intRandomNo + 40 Then
MsgBox "Your guess was too high by 40. Try again", ,cGreetingMsg
ElseIf FormatNumber(intUserNumber) > intRandomNo + 20 Then
MsgBox "Your guess was too high by 20. Try again", ,cGreetingMsg
ElseIf FormatNumber(intUserNumber) > intRandomNo + 10 Then
MsgBox "Your guess was too high by 10. Try again", ,cGreetingMsg
ElseIf FormatNumber(intUserNumber) < intRandomNo Then
MsgBox "Your guess was still too low. Try again, please", ,cGreetingMsg
strOkToEnd = "no"
End If
Else
MsgBox "Sorry. You did not enter a number. Try again.", , cGreetingMsg
End If
Else
MsgBox "You either failed to type a value or you clicked on Cancel. " & _
"Please play again soon!", , cGreetingMsg
strOkToEnd = "yes"
End If
Loop
すべてのヘルプはこれで大いに感謝しています。ありがとうございました。
コードのインデントを確認する必要があります。 –